How to Initialize Union


Although union members are referred in the same manner as that of structure members but all the members cannot be initialized together. This is because memory location of union is shared by different members of the union at different times. The size of union is equal to the size of the largest data members. So it would not be possible to initialize all members of a union together as value of latest initialized member otherwise the value of preceding member. You initialize a union member only when you are going to use it. The value in the union is the value which is assigned to its member recently.

Previous                                                                                    Next


Powered by Blogger.