-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathConstructorsDestructorsOrder.cpp
More file actions
50 lines (38 loc) · 1.39 KB
/
ConstructorsDestructorsOrder.cpp
File metadata and controls
50 lines (38 loc) · 1.39 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// =====================================================================================
// ConstructorsDestructorsOrder.cpp // Order Constructor/Destructor Invocations
// =====================================================================================
module modern_cpp:constructors_destructors_order;
namespace OrderConstructorInvocations {
class Something {
public:
Something() { std::cout << "c'tor Something" << std::endl; }
virtual ~Something() { std::cout << "d'tor Something" << std::endl; }
};
class Base {
public:
Base () { std::cout << "c'tor Base" << std::endl; }
virtual ~Base() { std::cout << "d'tor Base" << std::endl; }
};
class Derived : Base {
public:
Derived() { std::cout << "c'tor Derived" << std::endl; }
virtual ~Derived() { std::cout << "d'tor Derived" << std::endl; }
void printHello() const {
std::cout << "Hello!" << std::endl;
}
private:
Something m_something;
};
static void test_01() {
Derived myDerived;
myDerived.printHello();
}
}
void main_constructor_invocations()
{
using namespace OrderConstructorInvocations;
test_01();
}
// =====================================================================================
// End-of-File
// =====================================================================================