关于:的疑问,该怎么处理
关于::*的疑问
1 struct STRU
2 {
3 int a;
4 int b;
5 };
6
7 typedef struct STRU a;
8
9 class cl
10 {
11 ...
12 int a::*offset;
13 ...
14 }
第七行是什么意思?
第七行定义后所有STRU的实例都可以用offset么?
------解决方案--------------------
typedef struct STRU a;//定义类型a为 struct STRU,即a为struct STRU的别名
offset是指向STRU类型对象的成员的指针 ,使用前要先初始化
------解决方案--------------------
C++ Primer,目录里搜索“指向成员的指针”
1 struct STRU
2 {
3 int a;
4 int b;
5 };
6
7 typedef struct STRU a;
8
9 class cl
10 {
11 ...
12 int a::*offset;
13 ...
14 }
第七行是什么意思?
第七行定义后所有STRU的实例都可以用offset么?
------解决方案--------------------
typedef struct STRU a;//定义类型a为 struct STRU,即a为struct STRU的别名
offset是指向STRU类型对象的成员的指针 ,使用前要先初始化
------解决方案--------------------
C++ Primer,目录里搜索“指向成员的指针”