Re: call base class function or derived class function
"George" <George@discussions.microsoft.com> wrote in message
news:2CB66DF7-87CC-4CE8-9F80-F98C2E865BFE@microsoft.com
That's true... does that definition get entered into the v-table
No.
Since we can not instantise a abstract class with pure virtual
function, how could we check whether the pure function is in vtable
or not?
You could a) look at vtable under debugger, or b) try to call the
virtual function from base class constructor (which, technically,
exhibits undefined behavior, but on MSVC it produces a useful
diagnostic).
Can we develop some code to verify from RTTI point of view whether or
not pure virtual function is in vtable or not?
I don't understand this question. What does RTTI have to do with
anything?
There is no way for a conforming program to call an implementation of a
pure virtual function via virtual dispatch (it is only possible by using
a qualified name, which suppresses virtual dispatch).
Further, your question doesn't make sense from the C++ standard point of
view. The standard never says that virtual functions must be implemented
using a vtable or, indeed, any other specific mechanism. It only
describes how such functions should behave. It's up to the compiler to
implement this behavior in any way it chooses. So any discussion of
vtables is necessarily implementation-specific.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925