On Mon, 14 Jul 2003 10:12:16 -0700, Ramiraf <bl**@blah.com> wrote:
I have a void * variable1, which is really a pointer to a class. I want
to copy the class itself (not just the pointer) onto another void *
variable2, using the variable1's class's copy constructor (I need to do
more than just a shallow copy). Is there any way to do this? Thanks in
advance.
Steve
The key in doing a deep copy is performing a cast on your pointer to
get to the goodies in the class itself. You can use an old C-style
cast, or one of the new C++ casts, dynamic_cast, static_cast, etc.
Once youv'e casted to your class, you can call an operator= you have
implemented, or some funky deep-copy global method youv'e written;
whatever flavor poison you choose.
A bigger question is, why have you casted down your class pointer to
void*? There are very often good, valid reasons to do so. But using
void* as a generic pointer is usually (IMO) an over-used, cliche hack
around bad design.
</dib>
John Dibling
email:
dib@substitute_my_full_last_name_here.com
Witty banter omitted for your protection