In implementations of pure virtual classe (B_Impl below) do we need to define all methods corresponding to all derived pure virtual classes (A and B) even if we are also deriving from implementation classes (A_Impl). I have following pure virtual classes:
class A
{
public:
virtual bool M1() = 0;
virtual ~A() = default;
};
class A_Impl
{
public:
bool M1() override { return true;}
virtual ~A_Impl() = default;
};
class B : public A
{
public:
virtual ~B()=default;
virtual bool M2() = default;
}
class B_Impl : public B, public A_Impl
{
public:
virtual ~B_Impl() = default;
bool M2() override { return true; }
}
void main()
{
B_Impl bimpl();
return;
}
On compiling this I am getting following error: invalid new-expression of abstract class type 'B_Impl' because the following virtual functions are pure within ‘B_Impl’: A::M1()
Any help is appreciated.
Thanks and regards, Deepak
Aucun commentaire:
Enregistrer un commentaire