对象成员数据的存放

 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 }

 

posted @ 2017-06-07 09:43  w6811645  阅读(202)  评论(0编辑  收藏  举报