Board index » delphi » vptr and vtbl placement in object layouts as done by borland

vptr and vtbl placement in object layouts as done by borland

hi,
i defined two classes as shown below and compiled them using
 borland's 5.5.1 command line compiler,
case i:
 class a{ };
 class b : public virtual a { } ;

 the o/p as generated by the compiler was :
 size of a = 8
 size of b = 16

 i fail to figure out 16 bytes of memory for b...(can you explain this)

Yes. A virtual base is identified by a pointer in the derived class. Are you

Quote
>> case ii:

 class a{ public: virtual void f() {} };
 class b : public virtual a { } ;
 the o/p was:
 size of a = 4
 size of b = 12
 once again b occupies 12 bytes... (can you explain this also)

 i guess 4 bytes for vptr + 4 bytes for ptr to virtual base + 4 bytes for  what???

 anxiously waiting for your reply...
 vivek

 

Re:vptr and vtbl placement in object layouts as done by borland


Quote
vivek wrote:

> i defined two classes as shown below and compiled them using
>  borland's 5.5.1 command line compiler,

Please post your questions to more than one newsgroup. Especially not to
newsgroups that deal with a differrent compiler that what you are using.

And please read the newsgroup descriptions and guidelines at
http://www.borland.com/newsgroups

Re:vptr and vtbl placement in object layouts as done by borland


Quote
On Sat, 19 May 2001 11:48:57 +0200, Thomas Maeder <mae...@glue.ch> wrote:
>Please post your questions to more than one newsgroup.

<g> As if he needs your encouragement to do so. ;-))
Allow me to supply the missing negation:
Please don't post your questions to more than one newsgroup.

--
Wayne A. King
(ba...@torfree.net, wayne.k...@ablelink.org,
 wak...@idirect.com, Wayne_A_K...@compuserve.com)

Other Threads