0
類
內使用變量我有類此結構:從父
class A {
class B;
class C;
int updates = 0; // invalid use of non-static data member 'A::updates'
C* example;
class B {
public:
// ...
void up_plus() {
updates++; // problem here is too
}
// And some other methods.......
};
class C : public B {
public:
int size;
// ...
void sizeup() {
example->size++; // invalid use of non-static data member 'A::header'
}
// And some other methods....
};
};
我的問題是,我怎麼能解決這個結構呢?在Java中這將工作,但這裏有一個問題。
難道你不想讓B繼承A嗎?或者更新成爲A的靜態成員? – steiner
http://stackoverflow.com/questions/9590265/invalid-use-of-non-static-data-member – tty6