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
How do you clear a buffer in c++?
What is the standard template library (stl)?
Explain one-definition rule (odr).
What is iostream in c++ used for?
Differentiate between a pointer and a reference with respect to c++.
What is scope in c++ with example?
Explain unexpected() function?
What do you mean by late binding?
What is #include c++?
Should a constructor be public or private?
What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal
What is a down cast?
Is java made in c++?
Is set c++?
What is the basic concept of c++?