In constructor inheritance who call first and execution first ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

In constructor inheritance who call first and execution first ?

8th Jul 2019, 8:45 AM
Soumyadip Saha
Soumyadip Saha - avatar
2 Answers
+ 3
#include <iostream> using namespace std; class Parent { public: Parent() { cout << "Parent's constructor\n"; } ~Parent() { cout << "Parent's destructor\n"; } }; class Child : Parent { public: Child() { cout << "Child's constructor\n"; } ~Child() { cout << "Child's destructor\n"; } }; int main() { Child c; return 0; } Run this code and see what happens
8th Jul 2019, 12:49 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 1
Can u give one example by passing 2 value ...
8th Jul 2019, 3:17 PM
Soumyadip Saha
Soumyadip Saha - avatar