Friday, June 28, 2013

Anonymous Unions in C++

Unions in C++ are special type of classes. We can declare member functions and variables with in the union in c++ (all 'C' features of union remain same). 
But in the unions all the data members share the same memory location.

    Union members are public by default as like structures.

     Anonymous unions are the special type unions with the no name and so we can not create object for that union. All the member data in the anonymous unions share same memory location. We can directly access the these members without any dot operator with in the block where these unions declared.