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

D. Stimits stimits at idcomm.com
Tue Aug 7 19:23:07 MDT 2001


"Scott A. Herod" wrote:
> 
> 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.

I doubt that it is completely defined. But some behaviors are, I suspect
the relative offset is mandatory for virtual inheritance. COM I think
abstracts interface declaration, separating it through a similar
table/memory shape, but works for an entire interface instead of one
function at a time, and combines it with a means to look for a guid (ask
Kelly about that, he was one of the people replying...he's Mr. Com Guy
too!). :)

D. Stimits, stimits at idcomm.com

> 
>   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
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list