Topic: vtbls (or bytewise copy of C++ objects)
Author: maalkadh@rodan.syr.edu (Misha'al A. Al-Kadhi)
Date: 21 Dec 1994 15:22:59 GMT Raw View
In article <3d5r26$1eo@triode.apana.org.au> rick@triode.apana.org.au (Richard Welykochy) writes:
>Misha'al A. Al-Kadhi (maalkadh@rodan.syr.edu) wrote:
>: Hi. Just a quick question regarding vtables. I understand that
>: there is no standard place to store vtables for a given
>: object, however, do all implementations require storing them
>: either at the beginning or the end of an object or can they
>: be stored in a completely independant location?
>
>Of course, this is an implementation detail, and one cannot rely
>on where the vtable will be stored. Why is this an issue?
Because if I wanted to do a literal byte-by byte memory copy of
an object from one place to another (actually to disk and back)
I believe that the vtables will be corrupted. I am also not
sure if merely copying from "the address of a pointer to teh object"
until "this address plus sizeof(object)" will copy the hidden tables.
I need to find a way of doing such a literal storage and retreival
without corrupting the vtables.
>
>: Second question (probably answered by teh first):
>: When I test for teh length of an object, will the
>: vtable length be included in this returned value
>: or is teh length only the length of the object
>: minus the vtable?
>
>Try sizeof(object) ... you will find that the size of an object
>includes any 'hidden' details used by the compiler implementor
>to realize an instance of the class.
>Try the same for MI classes, and you'll be suprised at the
>overhead you buy when using multiple inheritance.