我有2班(自愿尽可能简单)和我的工作Qt有关Mac OS X:
//Class A
class A
{
protected:
int getX(){return _x;};
private:
int _x;
};
//Class B
class B : A
{
void method(){qDebug() << this->getX();}
};
Run Code Online (Sandbox Code Playgroud)
并且编译器抛出:
错误:'getX'是'A'的私人成员
我错过了什么吗?我尝试过:
qDebug() << this->A::getX();
Run Code Online (Sandbox Code Playgroud)
哪个也行不通!