[lug] (OT) C++ ?, pointers to member functions

Tom Tromey tromey at redhat.com
Wed Aug 8 16:57:00 MDT 2001


>>>>> ">" == D Stimits <stimits at idcomm.com> writes:

>> I would expect that regardless of how vtables are layed out, if an
>> object uses virtual functions like f(), then you should be able to
>> refer to the function with a relative offset anyway.

I don't understand what you mean.

If you are talking about using C++ language features across, say,
shared objects, then that will work fine (with every compiler I've
heard of) if everything is compiled with the same compiler.

For instance, if you have one library which implements a base class
with a virtual function f, and then another library which has a
class derived from `base' which overrides `f', then your program can
call `obj->f' without fear; it won't matter where the actual class of
`obj' is implemented.


If you mean trying to somehow manipulate the vtable directly,
independently of the compiler, then you're in for disappointment.  The
layout really does change significantly.

Tom



More information about the LUG mailing list