【问题标题】:Class Inheritance from Pre-Existing Class C++ [closed]从预先存在的 C++ 类继承类[关闭]
【发布时间】:2013-09-24 23:42:45
【问题描述】:

我正在编写一个需要从另一个类继承的类的程序。我该怎么做呢?

我正在使用 Code::Blocks 12.11 进行编译

【问题讨论】:

  • 试试你最喜欢的搜索引擎,而不是浪费 SO 的时间。

标签: c++ class inheritance codeblocks


【解决方案1】:
class ChildClass : public ParentClass {
};

public 表示要将ParentClass 的所有成员公开(如果他们在ParentClass 中公开)。或者,您可以使用protected 或private 将ParentClass 的成员隐藏在ChildClass 中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-12
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多