我有一个基类和派生类。我需要访问派生类中基类的受保护成员。但是,Eclipse 不允许我访问数据成员,就好像它是派生类的成员一样,而不关心它是否被继承。我怎么做?
class BaseClass {
protected:
static int a;
int b;
}
class DerivedClass: public BaseClass {
void SomeMethod {
a=10; // cannot resolve symbol
b=10; // cannot resolve symbol
BaseClass::a=10; //does not complain
BaseClass::b=10; //does not complain
}
}