-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain03.cpp
More file actions
47 lines (44 loc) · 953 Bytes
/
Copy pathmain03.cpp
File metadata and controls
47 lines (44 loc) · 953 Bytes
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
#include <iostream>
class Demo
{
public:
int id;
Demo(const Demo &z1)
{
std::cout << "step in copy constructor" << std::endl;
id = z1.id;
std::cout << "step out copy constructor" << std::endl;
}
Demo() {}
Demo(int id_)
{
id = id_;
std::cout << "id = " << id << " constructed" << std::endl;
}
~Demo()
{
std::cout << "id = " << id << " destructed" << std::endl;
}
};
Demo z1(1);
void hf1()
{
std::cout << "step in hf1" << std::endl;
static Demo z2(2);
Demo z3(3);
std::cout << "step out hf1" << std::endl;
}
// g++ main03.cpp -std=c++11 -o tbd00.exe
int main()
{
std::cout << "step in main" << std::endl;
Demo z4(4);
z4 = 6;
{
std::cout << "step in sub-region" << std::endl;
Demo z5(5);
std::cout << "step out sub-region" << std::endl;
}
hf1();
std::cout << "step out main" << std::endl;
}