answersLogoWhite

0

unions conserves memory space..The amount of space allocated for union is based on the member which requires largest memory space...so unions are useful for applications involving number of variables,where values need not be assigned to all elements at one time.

AnswerIts used to save on space.

For eg. you have a struct for storing information about insurance policy holders. But there are three types of insurances: Home, Life, Auto. Now basic details about policyholders such as name, address, etc is the same no matter what insurance you are talking about. But certain details are different. So by making a union policyinfo in this struct which is a diff internal struct for each of these policies you can save on space. When you are entering info about a Home policy, then you use the common fields AND only the struct for home insurance. You do not even fill/care about the other structs in the union. Upon storage only the Home struct will be stored, and the others will be discarded. Keep a variable in the main struct which indicates the type of insurance policy and so, which of the structs in the union you want to use. This way, you have just one big structure for all policyholders, instead of three -- it provides a common interface and saves on storage.

===============

The above answers are not correct. Unions do not save memory or storage space. Unions allow the same area of memory to be accessed as different data types. The insurance example above would not work.

<><><>

Unions are useful (often in embedded programming) when it is needed to refer to a data item as two or more different types: e.g. it may be used as an integer for math, but an array of bytes for a serial transmission or a checksum calculation.
For memory preservation, since the space allocated for the union is as big as its biggest member.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What are the advantages and disadvantages of wokers being in a trade union?

Unions provide strength. Unions provide support. Unions protect.


When a firm operates globally it offers advantages such as?

It offers advantages such as greater negotiating power with labor unions.


What are the advantages of using Unions in a structure in C?

In case of structure each variables have their own storage location whereas for unions all the variables share a common memory location. In structure all the variables can be handled at a time but for union only a member can be handled at a time.


What are the advantages of using ict for a leaflet?

advantages of using ICT


Advantages of using Sat Nav?

what is the advantages of using a sat nav.


What are advantages and disadvantages of using a heligimbal?

what are the advantages and disadvantages of using a heligimbal


What are the advantages micrometer?

"What is the advantages of using micrometer?


What are the advantages of using a electronic diary?

What are all the advantages and disadvantages of using an electronic dairy?


What are the advantages of using a balance ball chair?

"The advantages of using a stability ball as a chair


Where can I find information about unions?

If you got to the nidirect website, they will give you details of unions with the advantages and disadvantages of joining. You can also go to the websites of specific unions to find out more. There will also be information at your workplace provided by union representatives. Often you can find out who these are on noticeboards or on the company Intranet.


What are the advantages and disadvantages to wal-mart of working with unions?

Advantages of working with unions for Walmart include improved employee relations, which can lead to higher job satisfaction and lower turnover rates. Unions can also facilitate better communication between management and employees, potentially enhancing productivity. However, disadvantages include increased labor costs due to higher wages and benefits negotiated by unions, as well as potential disruptions from strikes or labor disputes. Additionally, unions may limit Walmart's flexibility in making staffing and operational decisions.


What are Advantages of using a Grinding machine?

Nothing advantages