difference between structure and union.

Answers were Sorted based on User's Feedback



difference between structure and union...

Answer / truong nguyen

Regarding the struct, each item in the struct is allocated
in a separated memory. And the size of a struct object is
total size of all its items.
But with the union, all its items are in the same memory.
And the size of an union object is size of its item which
has largest size.

Is This Answer Correct ?    24 Yes 0 No

difference between structure and union...

Answer / siva sankari

struct employee
{
int a[20];// for tis size 20 was allocated in memory
char text;// for tis only 1byte of memory space is allocated
}
so totally 21 in size was allocated in memory space

union employee
{
int a[20];// for tis size 20 was allocated in memory
char text;// for tis only 1byte of memory space is allocated
}
but in union it takes only the maximum memory space so for each 20space totally 40 size was allocated in memory space

Is This Answer Correct ?    7 Yes 12 No

Post New Answer

More OOPS Interview Questions

What is abstract class in oop?

0 Answers  


What is basic concept of oop?

0 Answers  


What is difference between polymorphism and inheritance?

0 Answers  


How Do you Code Composition and Aggregation in C++ ?

3 Answers   IBM, NET,


what is abstract class ? when is used in real time ? give a exp

5 Answers  






Base class has two public data members. How can i derive a new class with one datamember as public and another data member as private?.

2 Answers  


What is polymorphism oop?

0 Answers  


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

0 Answers   IBM,


How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

1 Answers   IntraLogic,


OOP'S advantages of inheritance include:

1 Answers   Infosys,


What are the advantanges of modularity

2 Answers  


Why is abstraction needed?

0 Answers  


Categories