I also did experiment and the result is not the same as yours. There is a
for abstract base class.
Here are the content of vtable for base class in constructor and my code. I
also read your content of vtable, but confused. Could you post your code here
"George" <George@discussions.microsoft.com> wrote in message
news:74F39427-6E0E-46CA-9D92-EF3C79D99651@microsoft.com...
Thanks Igor,
You could a) look at vtable under debugger, or b) try to call the
I doubt whether method (a) works. You know we can not create an object of
abstract class, and we can only create an instance of derived class. How
could we monitor the vtable of the abstract base class to see whether the
pure virtual method of base class is in vtable of instance of abstract
base
class?
And if we can create an instance of derived class, it means it implements
the pure virtual method, then in the vtable of instance of derived class,
it
should be the virtual method of derived class, not the pure virtual method
of
abstract base class.
a) should work. You cannot create an object of abstract class type but that
is not a problem. I might be misreading the debugger but I think that the
abstract class' v-table is not needed and hence not created (since there
would never be a abstract class object so there never would be a need for
v-table pointer to point to it's v-table for call resolution). The abstract
base part of the derived object contains a pointer to the instantiable
derived class' v-tables as depending upon the dynamic type being created.
That v-table may have an entry for a abstract base class virtual function
that is not pure and not overridden by derived classes. In the debugger, I
see something like this:
- ptr 0x00981898 AbstractBase *
- [Derived] {...} Derived
- AbstractBase {...} AbstractBase
+ __vfptr 0x004041fc const Derived::`vftable' *
+ __vfptr 0x004041fc const Derived::`vftable' *
- ptr2 0x009818d8 AbstractBase *
- [Derived2] {...} Derived2
- Derived {...} Derived
- AbstractBase {...} AbstractBase
+ __vfptr 0x00404220 const Derived2::`vftable' *
+ __vfptr 0x00404220 const Derived2::`vftable' *
The hierarchy I chose looked like AbstractBase inherited by Derived
inherited by Derived2.