Topic: vtable structure


Author: "Paul D. DeRocco" <pderocco@ix.netcom.com>
Date: 1998/07/15
Raw View
Venkat Konuganti wrote:
>
> Any ideas on the possible implementations of vtable structures in C++.
>
> I read an article about it some where, but I couldn't remember.

In the implementations I've seen, it's always just an array of pointers
to functions. There is also a pointer to some sort of type
identification object in the vtbl, for the benefit of the typeid
operator and dynamic_cast.

Complications:

1) Some of the pointers point not to member functions but to thunks or
trampolines that offset the "this" pointer and then jump to the member
functions. This is necessary when the actual implementation of the
function is inherited from a second or later base class.

2) The type identification object isn't necessarily a type_info,
although one of the latter can be derived from the former.

3) The vtbl pointer within the object is generally in one of two places,
depending upon the implementation. Either it's at offset zero, or it's
past the end of the visible object, rounded up to the next boundary
that's legal for a pointer.

4) If an object has multiple polymorphic bases, it will have multiple
vtbls. This is because any operation inherited from a base class will
expect to be operating on a subobject whose vtbl is structured
appropriately for that particular base class. In some implementations,
the main vtbl for the entire derived object can be shared with the vtbl
for the first base class, since it begins with the set of function
pointers necessary for that base class.

--

Ciao,
Paul
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1998/07/15
Raw View
"Venkat Konuganti" <VReddy1@CPA.ml.com> writes:

>Any ideas on the possible implementations of vtable structures in C++.

The ARM (Annotated C++ Reference Manual by Ellis and Stroustrup)
contains a detailed discussion of possible implementations.

--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Marius C" <zalmoxe@planeteer.com>
Date: 1998/07/17
Raw View
What you mean vtable, arry of poinetrs to methods.
I that is you have to know what type of methds you store

typedef returnType (CBaseClass::*ptrToMembers)(type arguments)

ptrToMembers[] = Method1,Method2.... // methods of CBaseClass

to call them the obj type will solve he deferecing tof viruals

pSomeCBaseClassOrDerivedFromBaseObj->*ptrToMembers[xx](arg);
or
objCBaseClassOrDerivedFromBaseObj.*ptrToMembers[xx](arg);


you can keep there any methods even virtual memberFn


Venkat Konuganti wrote in message <6odbjm$3m0$1@news.ml.com>...
>Hi,
>
>Any ideas on the possible implementations of vtable structures in C++.
>
>I read an article about it some where, but I couldn't remember.
>
>Thanks in advance.
>Venkat

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Venkat Konuganti" <VReddy1@CPA.ml.com>
Date: 1998/07/13
Raw View
Hi,

Any ideas on the possible implementations of vtable structures in C++.

I read an article about it some where, but I couldn't remember.

Thanks in advance.
Venkat



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]