我需要从两个接口继承,这两个接口都具有相同的方法,在两种情况下都应该执行完全相同的操作。这段代码是否正确?我需要这种代理类。谢谢你的回答。
class InnerInterface {
virtual int getID() const = 0;
//...
};
class OuterInterface {
virtual int getID() const = 0;
//...
};
class Foo : public InnerInterface, public OuterInterface {
virtual int getID() const;
//all abstract methods
};
答案 0 :(得分:8)
是的,这是正确的。单个getID()方法可以覆盖两个虚方法。