-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathptr_test.cpp
More file actions
33 lines (24 loc) · 482 Bytes
/
Copy pathptr_test.cpp
File metadata and controls
33 lines (24 loc) · 482 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
#include <iostream>
#include <string>
#include <vector>
class Demo {
public:
int age;
};
void copy_test(Demo** p_demo, Demo demo) {
/*
p_demo->age = demo.age;
demo.age = 100;
*/
Demo* demo_1 = new Demo();
demo_1->age = 100;
*p_demo = demo_1;
}
int main(int argc, char* argv[]) {
Demo* p_demo = new Demo();
Demo demo;
demo.age = 10;
copy_test(&p_demo, demo);
std::cout << p_demo->age << std::endl;
return 0;
}