【发布时间】:2024-11-27 14:20:02
【问题描述】:
为什么基类中的受保护成员在派生类中无法访问?
class ClassA
{
public:
int publicmemberA;
protected:
int protectedmemberA;
private:
int privatememberA;
ClassA();
};
class ClassB : public ClassA
{
};
int main ()
{
ClassB b;
b.protectedmemberA; // this says it is not accesible, violation?
//.....
}
【问题讨论】:
标签: c++ inheritance protected private-members