What if I have this:
union{
vector intVec ;
vector floatVec ;
vector doubleVec ;
} ;
Of cours
You cannot have unions containing non-POD class types. Your sample will not compile.
You can use boost::variant
as a safe alternative to C unions. See the documentation on boost.org. You might, however, reconsider your design and use polymorphism instead. Depends on what you're trying to accomplish, of course.