Check the following code example:
The compiler gives me the following error:
cannot declare variable ‘d’ to be of abstract type ‘D’ because the following virtual functions are pure within ‘D’: virtual void C::c(A*)
I don't understand why the compiler doesn't accept it. The object used in the parameter is an extension of the original one used in the abstract class.
Any ideas?
Best regards,
Rafael
Code:
///////////////////////
class A
{
public:
int a;
};
///////////////////////
class B : public A {};
///////////////////////
class C
{
public:
virtual void c(A *a) = 0;
};
///////////////////////
class D : public C
{
void c(B *b) {}
};
///////////////////////
int main()
{
D d;
return 0;
}
cannot declare variable ‘d’ to be of abstract type ‘D’ because the following virtual functions are pure within ‘D’: virtual void C::c(A*)
I don't understand why the compiler doesn't accept it. The object used in the parameter is an extension of the original one used in the abstract class.
Any ideas?
Best regards,
Rafael
Comment