C++: using a base class as the implementation of an interface

前端 未结 5 1103
南方客
南方客 2020-12-14 16:01

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
{
          


        
5条回答
  •  余生分开走
    2020-12-14 16:17

    Base and Interface are totally different types. How is the compiler supposed to know that "myfunction" is related? You must implement it in Derived, even if that implementation merely calls the Base version.

提交回复
热议问题