从预先存在的类C++继承类

Class Inheritance from Pre-Existing Class C++

本文关键字:C++ 继承 存在      更新时间:2023-10-16

我正在编写一个程序,该程序需要一个从另一个类继承的类。我将如何做到这一点?

我正在使用代码::块 12.11 进行编译

class ChildClass : public ParentClass {
};

public说要公开ParentClass的所有成员(如果他们在ParentClass年公开)。或者,您可以使用protectedprivateChildClass 中隐藏ParentClass的成员。