R
ronak2121
All,
I am getting a linking error when trying to use multiple inheritance
with virtual methods.
Here is some sample code which illustrates my problem.
class A {
};
class B {
virtual void method()=0;
}
class C : public A, public virtual B{
virtual void method(){
//do something in here
}
}
class D : public virtual B{
}
class E : public C, public D{
}
I am getting a linking error saying that the vtable has an undefined
reference to the method method(). I do not understand why I am getting
this error and what I can do to fix it.
I would think that since class C already provides an implementation,
class E just inherits that method and everything is happy. Why is the
linker complaining? How can I fix this?
I am using gcc 4.1 on Fedora Core 5.
Thanks in Advance
I am getting a linking error when trying to use multiple inheritance
with virtual methods.
Here is some sample code which illustrates my problem.
class A {
};
class B {
virtual void method()=0;
}
class C : public A, public virtual B{
virtual void method(){
//do something in here
}
}
class D : public virtual B{
}
class E : public C, public D{
}
I am getting a linking error saying that the vtable has an undefined
reference to the method method(). I do not understand why I am getting
this error and what I can do to fix it.
I would think that since class C already provides an implementation,
class E just inherits that method and everything is happy. Why is the
linker complaining? How can I fix this?
I am using gcc 4.1 on Fedora Core 5.
Thanks in Advance