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

9th Sep 2017, 2:06 PM
Harsha Sanju
Harsha Sanju - avatar
1 Respuesta
+ 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
9th Sep 2017, 2:09 PM
Paul