C++ function overriding

前端 未结 6 2246
独厮守ぢ
独厮守ぢ 2020-12-30 01:48

I have three different base classes:

class BaseA
{
public:
    virtual int foo() = 0;
};

class BaseB
{
public:
    virtual int foo() { return 42; }
};

clas         


        
6条回答
  •  误落风尘
    2020-12-30 02:31

    Class Child will compile if derived from A, you just can't instantiate objects of that type.

    This might be valuable if you were going to override some functions from Base, and then derive again.

提交回复
热议问题