假设您要创建 Derived 类的接口,它看起来像这样:
class Derived : public Base
{
public:
foo();
}
class Base
{
public:
tii();
//many other methods
}
你会怎么做接口?如何使 Base::tii 对这个新界面可见(以及其他方法)?
class IDerived
{
public:
virtual foo() = 0;
// should I declare here tii() as a pure virtual function?
// but by doing it now there is ambiguity!
}
什么是好的策略?
新的派生类应该是这样的......
class Derived : public Base, public IDerived
{
//implement the real thing
}