Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Why does the Empty class size is 1 byte?
Can any one elaborate the answer.

thanks®ards
sarath
Posted

 
Share this answer
 
Comments
Alain Rist 9-Dec-10 12:39pm    
Verum :)
If it would be no byte at all then no object was created when instantiating it. You would otherwise get a null pointer and that would get you in much bigger trouble. So, the compiler just sizes it up to the smallest unit to give you at least something to reference when it is created. What would malloc(0), which is used internally to get the necessary space, do?

Good luck!
 
Share this answer
 
Just to mark its existence. Here is the discussion -

http://www.geekinterview.com/question_details/42847[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900