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 are the 3 pillars of oop?

0 Answers  


What is the types of inheritance?

0 Answers  


difference between structure and union.

2 Answers   ADP, Convergys,


What is the important feature of inheritance?

0 Answers   BPL,


Why do we need oop?

0 Answers  






for example A,B,C,D are class all the 4 class contain one method who() but the method who() implementaion is differnet among each class. the relation among the 4 class are A is base class and is inherited by B and C.and from this two B and C where D is inherited. the question is i want to display the output who() method in all the classes(A,B,C,D)the output of who() method is diferrent amond all the class(A,B,C,D) ------A------ virtuval who(print a) override | | who(print b) B C override who(print c) | | -------D------ override who(print d)

2 Answers  


Can we have a private constructor ?

12 Answers   HSBC, Ness Technologies, TCS, Wipro,


if u write a class do u write Assignment operator and copy constructor

1 Answers   Siemens,


Write a program to get the binary tree.

3 Answers   ABC,


3. Differentiate verification and validation.

1 Answers  


What does and I oop mean?

0 Answers  


1.what are two type of classe members called? 2.what is data hiding and data encapsulation? 3.how do you make a class member visible aouside its class? 4.what is the default visibility of a class data member? 5.what are the advantages of oop over the structured programing?

6 Answers  


Categories