difference between structure and union.
Answers were Sorted based on User's Feedback
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 |
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 |
What polymorphism means?
How is class defined?
Which is the only operator in C++ which can be overloaded but NOT inherited?
why c++ is a highlevel language
3 Answers Satyam, Tech Mahindra,
How many types of access specifier in c# and vb.net?
can we make a class static without using static keyword?
What are the 3 pillars of oop?
Write 7 differences between "Public" function and "Private" function?
what is the advantage in software? what is the difference between the software developer and Engineer
What is the important feature of inheritance?
hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.
Why do we use encapsulation in oops?