Why we are no use union instead of Structure? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why we are no use union instead of Structure?

C++

8th Oct 2017, 7:04 AM
Ali Raza Jilani
Ali Raza Jilani - avatar
4 Answers
+ 7
yeah right... in union ,only one member is accessed at a time ,it has more ambiguity......
8th Oct 2017, 11:08 AM
Swati Tiwari
+ 9
bcoz structure has following advantages : each member have their own memory space, it has less ambiguity, all members of structure can be accessed at a time......
8th Oct 2017, 8:22 AM
Swati Tiwari
+ 3
yeah this is right answer
8th Oct 2017, 10:55 AM
Ali Raza Jilani
Ali Raza Jilani - avatar
+ 3
in Union which member have larger data types it will becomes Union's size all member use that memory.......but in structure every member have its own memory and access any time........am I right?
8th Oct 2017, 11:02 AM
Ali Raza Jilani
Ali Raza Jilani - avatar