
26 May
2004
26 May
'04
4:27 p.m.
Making a transition between two inner states is the equivalent of destructing the derived class portion of the object but leaving the base class portion intact and then constructing a different derived class object on top of
"Andreas Huber" <ah2003@gmx.net> wrote: the
base class portion. This is of course not possible in C++ ....
It is sort of possible using placement constructors and destructors: - allocate enough of memory to hold largest derived object - construct derived object 1 - destruct derived object 1 but keep its base class data - construct derived object 2 on the same place and 'reuse' base class data Its rather dubious trick and probably relies on undefined behaviour but may work for typical compilers/situations. /Pavel