+ 2

Can anyone tell me the practical use of Unions in C++?

How Union can be helpful and its limitations in case.

4th Feb 2017, 8:57 AM
GeekyShacklebolt
GeekyShacklebolt - avatar
4 ответов
+ 2
union variables are used to get hardware interrupts in c++. these hardware interrupts can be used to control the working of hardware., like we can restrict mouse pointer,control keyboard like turning on and off caps etc...create archives change access rights etc...
4th Feb 2017, 5:01 PM
Richu Thankachan
Richu Thankachan - avatar
+ 2
Unions are usually used for polymorphism. Different types of data if they are recorded in the Union can be handled using only one way. About hardware interrupts are not sure... I don't know...
8th Feb 2017, 1:07 PM
SUPER_S
SUPER_S - avatar
+ 2
The limitation is necessary for the integrity of the contained data. For example, the Union of 4 bytes will not be able to put a double (8 bytes), so he reserves the largest possible size (8)
8th Feb 2017, 1:34 PM
SUPER_S
SUPER_S - avatar
+ 1
as far as i have gathered... Unions share a common memory place by different variables(one at a time). and it is also used to interrupt hardware working.
5th Feb 2017, 9:15 AM
GeekyShacklebolt
GeekyShacklebolt - avatar