+ 1
what is output?
#include<iostream> using namespace std; class a { public: a() { cout<<endl<<"mukesh Kumawat"; } void show() { cout<<endl<<"show is called"; } }; class b:public a { public: b() { cout<<endl<<"harish kUmawat"; } void display() { cout<<endl<<"display is called"; } }; int main() { b s; s.show(); s.display(); return 0; }
4 Réponses
+ 5
The output is...
mukesh Kumawat
harish kUmawat
show is called
display is called
what's the confusion?
+ 4
As per convention, when an object of the derived class is created, constructor of base class is called first and then the constructor is called (if exists). And when the same object is destroyed, destructor of the derived class in called first then the destructor of the base class.
0
but first run b() construction because taking b object.plz explain
0
thank you friends