Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ interface multiple inheritance with same method

I need to inherit from two interfaces which both have the same method which in both cases should perform exactly the same thing. Is this code correct or not? I need this for some kind of proxy class. Thanks for answers.

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
};
like image 632
Rusty Horse Avatar asked Apr 26 '11 13:04

Rusty Horse


1 Answers

Yes, this is correct. The single getID() method can override both virtual methods.

like image 99
Ernest Friedman-Hill Avatar answered Sep 20 '22 13:09

Ernest Friedman-Hill