-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (32 loc) · 711 Bytes
/
main.cpp
File metadata and controls
43 lines (32 loc) · 711 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
#include <iostream>
using namespace std;
class test
{
public:
void show()
{
cout<<"test.show"<<endl;
}
};
class CSmartPtr
{
public:
test* ts1;
void show()
{
cout<<"CSmartPtr.show"<<endl;
}
test* operator -> ()
{
return ts1;
}
};
int main()
{
CSmartPtr smartPtr1;
smartPtr1.ts1=(test*)new test();
smartPtr1->show(); //这里存在不清楚 smartPtr1->解析为smartPtr1.operator ->()返回一个指针
//show() 前面直接添加一个指针???这里编译器做了什么处理呢???
cout << "Hello world!" << endl;
return 0;
}