C++: What will be the output of following program?
What will be the output of following program?
class emp
{
} ;
void main( )
{
emp e ;
cout << sizeof ( e ) ;
}
The output comes out to be 1. Why 1? The 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.




Comments
Log in or create a user account to comment.