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


Please Help Members By Posting Answers For Below Questions

How do you clear a buffer in c++?

536


What is the standard template library (stl)?

621


Explain one-definition rule (odr).

644


What is iostream in c++ used for?

549


Differentiate between a pointer and a reference with respect to c++.

695






What is scope in c++ with example?

628


Explain unexpected() function?

582


What do you mean by late binding?

615


What is #include c++?

567


Should a constructor be public or private?

537


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

694


What is a down cast?

611


Is java made in c++?

580


Is set c++?

570


What is the basic concept of c++?

575