CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*Learning:
Initializer list order does not define the order of constructor calls
base class constructor is always first one to get called
then,
order of member variable constructor call is based on declaration in class
not based on declaration in Initializer list
For destructor call, it is always reverse of what was in construction order
*/
#include <iostream>
using namespace std;
class base
{
public:
base(int) {cout << "base ctor\n";}
~base() {cout << "base dtor\n";}
};
class member1
{
public:
member1(int) {cout << "member1 ctor\n";}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run