0
Anyone can explain this?? Generally a constructor of base class doesn't inherit to derived class..... But here I'm confused...
#include <iostream.h> using namespace std; class A { public : A() { pp cout<<1; } }; class B:public A { public: B() { cout<<2; } }; main() { A a; B b; } //output is 112
1 Antwort
+ 5
the constructior is not inherited, this is correct, but when you derive a class and make an instance of that derived class, the constructor of base class is called, then the derived class constructior