From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2004-05-26 11:27:45
"Andreas Huber" <ah2003_at_[hidden]> wrote:
> Making a transition between two inner states is the equivalent of
> 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
> 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk