-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc04052.cpp
More file actions
61 lines (46 loc) · 898 Bytes
/
src04052.cpp
File metadata and controls
61 lines (46 loc) · 898 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "stdafx.h"
#include <iostream>
using namespace std;
class CMyData {
public:
CMyData() {
cout << "CMyData()" << endl;
}
~CMyData() {
cout << "~CMyData()" << endl;
}
CMyData(const CMyData &rhs) :m_ndata(rhs.m_ndata) {
cout << "CMyData(const CMyData &rhs)" << endl;
}
CMyData(const CMyData &&rhs) :m_ndata(rhs.m_ndata) {
cout << "CMyData(const CMyData &&rhs)" << endl;
}
CMyData& operator=(const CMyData &) = default;
int GetData(void) const {
if (m_ndata != NULL)
{
return m_ndata;
}
return 0;
}
void SetData(int nparam) {
m_ndata = nparam;
}
private:
int m_ndata;
};
CMyData TestFunc(int param) {
cout << "testfunc begin" << endl;
CMyData a;
a.SetData(param);
cout << "testfunc end" << endl;
return a;
}
int main() {
CMyData b;
cout << "main begin" << endl;
b = TestFunc(10);
cout << "main end" << endl;
CMyData c(b);
return 0;
}