answersLogoWhite

0

union is similar to structure .The distinction is in terms of storage. In structure each member has it own storage location but in union all the members use the same location. It can handle only one member at a time.

example.

union u

{

int a;

char b[4];

};

A union may contain structure(s) and a structure may contain union(s).

A structure (or an union) may contain unnamed unions (and structures), a useful feature and worth getting to know.

Example:

typedef union MYUNION {

. struct {

. . int x;

. . int y;

. } int_coord;

. struct {

. . double x;

. . double y;

. } dbl_coord;

} MYUNION;

It's a fragment of memory shared by multiple variables.

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

What is anonymous objects in c plus plus?

There is no such thing as an anonymous object in C++ (no such term is defined by the standard). You can have anonymous classes, anonymous unions or unnamed objects, but never anonymous objects. Consider the following: int* p = new int(); This creates two variables: a pointer variable on the stack (named p) and an integer variable on the heap (unnamed). Although the int on the heap has no name of its own, it is identified by dereferencing the address stored in p (*p), so it is not strictly anonymous. struct foo { //... foo operator++(int); }; In the above example, the int parameter is unnamed, but since it is never referenced (because it is not used) it is not strictly anonymous. You might consider the following an anonymous object: class foo{}; void bar(foo& f){} int main() { bar( foo() ); } The instance of foo in main is merely unnamed. When passed to bar, it is identified by the f reference, so it cannot be regarded as an anonymous object. Upon returning from bar, the unnamed instance falls from scope. At best this can be described as a temporary unnamed object, but not an anonymous object.


Write a c program to generate student mark details using union and find total and average and grade?

write a c program to display marks,total,average,grade using union


How memory space is occupied by union variables in C programming language?

A union is an aggregate of members that share the same memory address. The size of a union is determined by the largest member.


What is the difference between a class and a union in c plus plus?

The data members of a class are each allocated separate memory addresses. A union's members are all mapped to the same address. If you change the value of one union member, you change them all.


What is anonymous object in java?

Objects without their declarations known as Anonymous Objects. these are known as use & throw objects because these are died after one time use.

Related Questions

In contrast to artists in ancient Greece artists in Roman were?

anonymous, poorly paid workers


What has the author Herbert C Cornuelle written?

Herbert C. Cornuelle has written: 'Mr. Anonymous'


How do you solve A intersecting B union C?

The answer depends on whether you mean A intersecting (B union C) or (A intersecting B) union C.


What is anonymous class in .Net?

Anonymous classes are the temporary classes that contain some constant member variables like -var Student = new { ID = 2, Name = "Madhuri" }We also have anonymous methods in .Net-Anonymous methods is a new feature in C# 2.0 that lets you define an anonymous method called by a delegate.


Is it true that if a union c equals b union c then a equals b?

No- this is not true in general. Counterexample: Let a = {1,2}, b = {1} and c ={2}. a union c = [1,2} and b union c = {1,2} but a does not equal b. The statement be made true by putting additional restrictions on the sets.


What is the complement of the union B and C?

not (b or c) = (not b) and (not c)


Where on the internet c n i find a free download of the Pills Anonymous big book?

You can download the Pills Anonymous big book on the free Kindle Reading App or on your Kindle in the internet.


Prove if a union c equals b union c and a intersect c equals b intersect c then a equals b?

suppose x is in B. there are two cases you have to consider. 1. x is in A. 2. x is not in A Case 1: x is in A. x is also in B. then x is in A intersection B. Since A intersection B = A intersection C, then this means x is in A intersection C. this implies that x is in C. Case 2: x is not in A. then x is in B. We know that x is in A union B. Since A union B = A union C, this means that x is in A or x is in C. since x is not in A, it follows that x is in C. We have shown that B is a subset of C. To show that C is subset of B, we do the same as above.


What is the venn diagram of a union b union c?

Venn diagram is represented with the help of circles. Union of a, b and c is shown by the three fully shaded somewhat overlapped circles. Result will be the elements that is in all three sets(a,b,c).


Structure and union in c?

Both usable.


Example for union in c?

union intlong { int i; long l; long long ll; };


Who is anonymous who hacks websites?

Anonymous is an Collective Idea. anonymous is realy an idea, anonymous isn't a hacking group. there are computer hackers, who are joined to the Idea Anonymous, that's all. Anonymous is in our hearts, and we in theirs for freedom. everybody who lives for freedom,is anonymous. Anonymous could be you, could be me, could be your family, everybody is anonymous.