What be the size of an empty object ?

class emp

{

} ;

void main( )

{

emp e ;

cout << sizeof ( e ) ;

}

Ans: The output comes out to be 1. Why 1? Size of an object is the sum of all its data members. If the class does not have any members the minimum possible memory gets allocated for the class which is one byte.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>