Hello everyone,
In the following multiple inheritance sample code, I have tested in class Derived, there are two __vfptr, pointing to the virtual function table for Foo and Goo repectively -- i.e. 8 bytes, 2 pointer on 32-bit machine.
My questions,
1. Why two __vfptr is needed? Why not just one?
2. class Derived has its own virtual method func2, why it does not have its own virtual function table pointer?
Code:
class Foo {
public:
virtual int func() {return 1;};
};
class Goo {
public:
virtual int func() {return 2;};
};
class Derived: Foo, Goo {
public:
virtual int func2() {return 3;};
int increase() {return -1;};
int decrease() {return -2;};
};
int main()
{
Derived d;
int size;
size = sizeof (d); // size is 8, two __vfptr?
return 0;
}
thanks in advance,
George