【发布时间】:2015-06-02 14:31:26
【问题描述】:
假设我有一个继承自另一个接口(纯抽象类)的接口
class BaseInterface
{};
然后在 BaseInterface 上构建另一个接口
class ExtendedInterface : public BaseInterface
{};
现在,我有一个实现 BaseInterface 的具体类:
class Base : public BaseInterface
{};
现在,我想实现 ExtendedInterface,但由于我已经有了 Base,我想用 base 填写 BaseInterface 成员。例如:
class Extended : public ExtendedInterface, public Base
{};
这似乎不起作用。我抱怨我无法实例化扩展,因为它是一个抽象类。我可以让它工作的唯一方法是使用虚拟继承,但随后我收到关于通过支配继承的编译器警告。
【问题讨论】:
标签: c++ inheritance multiple-inheritance class-design