struct S1 {
int a;
};
struct S2 {
int b;
S1 s;
};
int S2::*ptrB = &S2::b; // pointer to data member 'b'
int S2::*ptrA = ? // pointer to data member 'a'
是否可以将成员指针指向a
成员变量?
编辑:
很多人问我为什么需要这个。我有许多重复的代码行,如下所示:
object.get("struct1.struct2.var1", &record.struct2.var1);
object.get("struct1.struct3.var1", &record.struct3.var1);
object.get("struct1.struct2.var1", &record2.struct2.var1);
object.get("struct1.struct3.var1", &record2.struct3.var1);
我的目标是创建字符串和成员指针列表,然后遍历此列表。