-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstructOrder.cpp
90 lines (78 loc) · 1.75 KB
/
ConstructOrder.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* \file ConstructOrder.cpp
* \brief Construct order
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
class Base1
{
public:
Base1() { STD_TRACE_FUNC; }
~Base1() { STD_TRACE_FUNC; }
};
//-------------------------------------------------------------------------------------------------
class Base2
{
public:
Base2() { STD_TRACE_FUNC; }
~Base2() { STD_TRACE_FUNC; }
};
//-------------------------------------------------------------------------------------------------
class Field
{
public:
explicit Field(std::string a_name) :
_name{a_name}
{
std::cout << "\t\tField: " << _name << std::endl;
}
~Field()
{
std::cout << "\t\t~Field: " << _name << std::endl;
}
private:
const std::string _name;
};
//-------------------------------------------------------------------------------------------------
class A :
public Base1,
public Base2
{
public:
const Field f1{"f1"};
const Field f2{"f2"};
const Field f3{"f3"};
static const Field fs; ///< static as 2-nd
static const inline Field fsi {"f_static_inline"}; ///< static as 1-st
A() { STD_TRACE_FUNC; }
~A() { STD_TRACE_FUNC; }
};
/* static */ const Field A::fs{"f_static"};
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
{
A a;
}
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
Field: f_static_inline
Field: f_static
::: Base1 :::
::: Base2 :::
Field: f1
Field: f2
Field: f3
::: A :::
::: ~A :::
~Field: f3
~Field: f2
~Field: f1
::: ~Base2 :::
::: ~Base1 :::
~Field: f_static
#endif