answersLogoWhite

0

What is the usage of union in CPP?

Updated: 12/20/2022
User Avatar

Wiki User

14y ago

Best Answer

A union in C or C++ is like a structure, except that each element in the structure starts at the same memory address. It is useful for storing more than one type of data, but only one at a time, in the same memory location.

It can also be used for the potentially unsafe technique of looking at the bit patterns of one data type using another data type. (It is unsafe because internal memory organization of bits and bytes is an implementation specific thing, and depending on one particular organization can lead to incorrect program behavior.)

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the usage of union in CPP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What do the initials CBF and CPP stand for?

CPP


When was CPP Group created?

CPP Group was created in 1980.


Are function prototypes necessary in C and Cpp?

Yes. Without prototypes you must ensure all definitions are declared forward of their usage. This isn't always possible. Separating the prototypes from the definitions means you can #include the prototypes forward of their usage, and place the actual definitions anywhere you like.


What is CPP Studios Event GmbH's population?

CPP Studios Event GmbH is a company, not a population. It does not have a population as it is an entity, not a community or group of people. Can I help you with anything else?


When was CPP Studios Event GmbH created?

CPP Studios Event GmbH was created in 1983.


CPP Program for Implementing Knuth-morris-pratt pattern matching algorithm?

what is the pure algorithm instead of cpp program?


When did CPP start?

I believe it was in 1967


What is a shorted CPP switch?

Bu11sh1+


Is a military pension clawed back at 65 if you take cpp at age 60?

No, a military pension is separate from CPP. Your military pension will not be clawed back if you choose to take CPP at age 60. However, your CPP may be reduced if you start taking it before the age of 65, but this will not affect your military pension.


How the c and cpp extension files can be retrived using FIND command in Linux?

find . -iname '*.c' -o -iname '*.cpp'


What is the history of cpp-npa-ndf?

Later then we know that ninoy aquino has been a big part in the creation of cpp/npa/ndf.


What is the difference between bopp and cpp film?

CPP film is a plastic extrusion made of polypropylene. BOPP films are bi-directional polypropylene. CPP film is high gloss, has good transparency, is heat resistant, and water resistant.