【发布时间】:2013-05-16 00:26:08
【问题描述】:
例如在以下示例中,我希望能够将x.nest1.n 和y.nest1.n 设置为不同 值,但强制x.nest1.n === x.nest2.n 和y.nest1.n === y.nest2.n - 如何实现这一点?
struct A {
...
struct B {
static int n;
...
};
B nest1;
B nest2;
};
int A::B::n = 0;
...
A x, y;
x.nest1.n = 1;
y.nest1.n = 2; // want to be able to set seperately from x.nest1.n
std::cout << x.nest1.n; // prints 2 :(
【问题讨论】:
-
道歉 -
x.nest1.n- 错字 - 已修复
标签: c++ class static-members