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

Scott A. Herod herod at interact-tv.com
Tue Aug 7 16:50:07 MDT 2001


Thanks Dan,

  Of course my copy of Stroustrup is at home.  I'll look tonight.
Is the format of the vtable specified in the C++ standard?  A friend
and I were discussing this issue last week with respect to MS's COM
definition.

  Also, I've already given up and am just passing around the mutex and
pipe so everybody has got to manage locking themselves.  I'll fix it
in release 2.0.

Scott

"D. Stimits" wrote:
> 
> "Scott A. Herod" wrote:
> >
> > This is off topic but there are a lot of experts here.
> >
> > How can I pass a pointer to a non-static member function?
> >
> > I've got a static sample below but really want b::fp to be
> > non-static.  Must I use a static, have it reference a non-static
> > and pass around a 'this' pointer?
> 
> For that to work, it needs to be a virtual function. And in the case of
> a virtual function, you need to use it only as a relative offset, from
> the object itself. If you have the paperback Stroustrup book, 3rd
> edition, see section 15.5, pages 418 through 420. When the function
> becomes virtual, the vtable offset is like a blueprint that will remain
> consistent even across memory spaces, so you could even use this to
> point to member functions of an object from a dynamic library that is
> mapped to some other memory space (the "shape of the offset" will remain
> constant).
> 
> D. Stimits, stimits at idcomm.com



More information about the LUG mailing list