Hacker News new | ask | show | jobs
by sltkr 4913 days ago
No, you really can't do this. If you think you can, tell me what you think the output of this program will be:

  class X
  {
  	int a;
  public:
  	X() : a(123) { }
  	int get_a() { return this ? a : 1; }
  };
  
  class Y
  {
  	int b;
  public:
  	Y() : b(456) { }
  	int get_b() { return this ? b : 2; }
  };
  
  class Z : public X, public Y
  {
  	int c;
  public:
  	Z() : c(789) { }
  	int get_c() { return this ? c : 3; }
  };
  
  #include <iostream>
  int main()
  {
  	Z *z = NULL;
  	std::cout << z->get_a() << '\n';
  	std::cout << z->get_b() << '\n';
  	std::cout << z->get_c() << '\n';
  }