J
Jeff Mallett
VC++.NET gave me Compiler Error C2621, which states,
"A union member cannot have a copy constructor."
Yikes, that can't be true! As I understand it, *all*
class objects have copy constructors, since if they
aren't explicit, one is implicitly generated. If this
were true, class objects could not be members of a union,
but I know they can be.
I assume what is meant is that a union member can't have
a "non-trivial" copy-constructor, which is what the C++
states. It seems that any class with *any* virtual
functions will have a non-trivial copy-constructor. Does
this mean that there's no way I can have a derived object
that overrides member functions as a member of a union?
If so, then why? The sizeof the object is certainly
fixed and known at compile time.
Thanks.
"A union member cannot have a copy constructor."
Yikes, that can't be true! As I understand it, *all*
class objects have copy constructors, since if they
aren't explicit, one is implicitly generated. If this
were true, class objects could not be members of a union,
but I know they can be.
I assume what is meant is that a union member can't have
a "non-trivial" copy-constructor, which is what the C++
states. It seems that any class with *any* virtual
functions will have a non-trivial copy-constructor. Does
this mean that there's no way I can have a derived object
that overrides member functions as a member of a union?
If so, then why? The sizeof the object is certainly
fixed and known at compile time.
Thanks.