Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 C++ 中继承类的全部或全部部分(私有除外)?
class A { }
clas B : ...? { }
如果您问是否可以使派生类可以看到私有成员,答案是否定的——这就是它们是私有的原因。protected如果您希望派生类能够访问它们,请使用基类中的成员。
protected
如果您可以继承私有成员,那么访问私有成员所要做的就是从父类继承项目。