C++ Programming - Unions in C++

Default access to a union is public, it can contain member functions and member data.

Other than that there are some more specialties for unions in C++.


  • It can't have a static data members or a member of reference type.
  • It can't have virtual functions.
  • It can't be used as a base class nor it can have base class.
  • An object of a class with a construct or a destructor or a user-defined assignment operator cannot be a member of a union

Labels:


About this entry