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.

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers