What is size of a empty class?
Answer Posted / shiv chidambar
size of empty class is 1 byte.
because to indicate class existance in memory 1 byte is
allocated to indicate that class is present.
if the class is empty then there should some kind of
mechanism to indicate or to show this class is present.
if memory (1 byte) not alloacted such a empty class then how
we know that class is present but in programme that class is
written? so for that 1 byte allocated to indicate class
existance.
this happens only for emty classes(Consider example of
tagging interface in java which is empty class).
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What does return 0 do in c++?
What is a constant reference?
What are the uses of pointers?
What are the three forms of cin.get() and what are their differences?
What is the keyword auto for?
Which of the following is evaluated first: a) && b) || c) !
Can a constructor be private?
Why is the function main() special?
What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required
Can we overload operator in c++?
What are the differences between java and c++?
What does namespace mean in c++?
What are the restrictions apply to constructors and destructors?
Is swift faster than go?
Explain some examples of operator overloading?