M
Mattias B
Hello!
I have s quick question regarding multiple ineritance that I hope that
someone will have the time to look at. I have the following classes that
I try to compile and use:
class A
{
public:
virtual void foo() = 0;
};
class B : public A
{
public:
virtual void bar() = 0;
};
class A_Impl : public A
{
public:
void foo() { }
};
class B_Impl : public A_Impl, public B
{
public:
void bar() { }
};
Now when I try to create an instance of B_Impl I get the following error
message when I try to compile with gcc:
main.cpp: In function `int main()':
main.cpp:7: cannot allocate an object of type `B_Impl'
main.cpp:7: because the following virtual functions are abstract:
A.h:7: virtual void A::foo()
Can anyone tell me why this is? Surely B_Impl has inerited A_Impl's
implementation of void foo()?
Regards,
Mattias
I have s quick question regarding multiple ineritance that I hope that
someone will have the time to look at. I have the following classes that
I try to compile and use:
class A
{
public:
virtual void foo() = 0;
};
class B : public A
{
public:
virtual void bar() = 0;
};
class A_Impl : public A
{
public:
void foo() { }
};
class B_Impl : public A_Impl, public B
{
public:
void bar() { }
};
Now when I try to create an instance of B_Impl I get the following error
message when I try to compile with gcc:
main.cpp: In function `int main()':
main.cpp:7: cannot allocate an object of type `B_Impl'
main.cpp:7: because the following virtual functions are abstract:
A.h:7: virtual void A::foo()
Can anyone tell me why this is? Surely B_Impl has inerited A_Impl's
implementation of void foo()?
Regards,
Mattias