+ 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; }

5th Apr 2017, 8:02 AM
Harish kumawat
Harish kumawat - avatar
4 odpowiedzi
+ 5
The output is... mukesh Kumawat harish kUmawat show is called display is called what's the confusion?
5th Apr 2017, 8:48 AM
Renjith M
Renjith M - avatar
+ 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.
5th Apr 2017, 9:05 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
0
but first run b() construction because taking b object.plz explain
5th Apr 2017, 8:55 AM
Harish kumawat
Harish kumawat - avatar
0
thank you friends
5th Apr 2017, 10:50 AM
Harish kumawat
Harish kumawat - avatar