The following code only works if you uncomment the line
virtual void FuncA() { ImplA::FuncA(); }
in the ImplB class, otherwise I get a compiler error:
cannot create an instance of an abstract class ... FuncA (void) ': abstract
Question: why doesn’t it get the implementation for FuncA() from the inherited ImplA ?
class InterfaceA { public: virtual void FuncA()=0; }; class InterfaceB : public InterfaceA { public: virtual void FuncB()=0; }; class ImplA : public InterfaceA { public: virtual void FuncA() { printf("FuncA()\n"); } }; class ImplB : public ImplA, public InterfaceB { public:
c ++ inheritance abstract-class
perry
source share