对象成员数据的存放

 1 #include <iostream>
 2 using namespace std;
 3 
 4 class TestObject
 5 {
 6 public:
 7     TestObject()
 8     {
 9         x = 10;
10         y = 20;
11         z = 30;
12 
13         a = 'c';
14     }
15 
16 public:
17 
18     int x;
19     int y;
20     int z;
21     char a;
22 };
23 
24 int main()
25 {
26     TestObject *p = new TestObject;
27     int *q = (int *)p;
28     q++;
29     q++;
30     char *pch = (char *)q;
31     pch++;
32     //char *pch = (char *)q++;
33 
34 
35     cout << *pch << endl;
36 
37 
38     system("pause");
39     return 0;
40 }
原文地址:https://www.cnblogs.com/Froger/p/6955440.html