In C++ is it possible to use another base class to provide the implementation of an interface (i.e. abstract base class) in a derived class?
class Base
{
virtual void myfunction() {/*...*/};
}
class Interface
{
virtual void myfunction() = 0;
}
class Derived
: public Base, public Interface
{
// myfunction is implemented by base
}
The above should compile, but doesn't actually work. Is there any way to achieve this effect?
In case anyone cares, the reason for wanting this is that it make sense (for my application) to use a generic library from another project/namespace to provide the implementation of an interface in my project. I could just wrap everything, but that seems like a lot of extra overhead.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…