1 #include<iostream>
2 using namespace std;
3
4
5
6 int main()
7 {
8 int i = 10;
9 int *p;
10 p = &i;
11 int *p1;
12 p1 = p;
13
14 /*
15 &i:003AFA30
16 &p:003AFA24
17 p:003AFA30
18 *p:10
19 p1:003AFA30
20 &p1:003AFA18
21 *p1:10
22
23 => &i = p = p1
24 => *p = *p1
25 */
26 cout << "&i:"<< &i << endl;
27 cout << "&p:" << &p << endl;
28 cout << "p:" << p << endl;
29 cout << "*p:" << *p << endl;
30 cout << "p1:"<< p1 << endl;
31 cout << "&p1:" << &p1 << endl;
32 cout << "*p1:" << *p1 << endl;
33 cout << "--------------------------------" << endl;
34
35
36 int **p2 = NULL;
37 int *p3 = NULL;
38 int *p4 = NULL;
39 int j = 20;
40
41 p3 = &j;
42 p4 = p3;
43 p2 = &p3;
44 /*
45 &j:0074FBF8
46 p3:0074FBF8
47 *p3:20
48 &p3:0074FC10
49 p4:0074FBF8
50 &p4:0074FC04
51 *p4:20
52 p2:0074FC10
53 &p2:0074FC1C
54 *p2:0074FBF8
55 **p2:20
56
57 => &j = p3 = p4
58 => p2 = &p3
59 => *p2 = &j
60 => **p2 = j
61 */
62 cout << "&j:" << &j << endl;
63 cout << "p3:" << p3 << endl;
64 cout << "*p3:" << *p3 << endl;
65 cout << "&p3:" << &p3 << endl;
66 cout << "p4:" << p4 << endl;
67 cout << "&p4:" << &p4 << endl;
68 cout << "*p4:" << *p4 << endl;
69 cout << "p2:" << p2 << endl;
70 cout << "&p2:" << &p2 << endl;
71 cout << "*p2:" << *p2 << endl;
72 cout << "**p2:" << **p2 << endl;
73 cout << "--------------------------------" << endl;
74
75 int ***k, **k1, *k2;
76 int m = 30;
77
78 k2 = &m;
79 k1 = &k2;
80 k = &k1;
81 /*
82 &m:009BFB68
83 k2:009BFB68
84 &k2:009BFB74
85 *k2:30
86 k1:009BFB74
87 &k1:009BFB80
88 *k1:009BFB68
89 k:009BFB80
90 &k:009BFB8C
91 *k:009BFB74
92 **k:009BFB68
93 ***k:30
94
95 => &m = k2 = *k1 = **k
96 => &k2 = k1 = *k
97 => &k1 = k
98 => *k2 = ***k
99 */
100 cout << "&m:"<<&m << endl;
101 cout << "k2:" << k2 << endl;
102 cout << "&k2:" << &k2 << endl;
103 cout << "*k2:" << *k2 << endl;
104 cout << "k1:" << k1 << endl;
105 cout << "&k1:" << &k1 << endl;
106 cout << "*k1:" << *k1 << endl;
107 cout << "k:" << k << endl;
108 cout << "&k:" << &k << endl;
109 cout << "*k:" << *k << endl;
110 cout << "**k:" << **k << endl;
111 cout << "***k:" << ***k << endl;
112
113 cout<<"hello"<<endl;
114 system("pause");
115 return 0;
116 }