Size of class
CASE without member
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
class temp
{
public:
private:
};
int main()
{
temp obj1;
cout<<sizeof(obj1);
return 0;
}
|
output = 1
CASE with member
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
class temp
{
public:
private:
int a; // member variable
};
int main()
{
temp obj1;
cout<<sizeof(obj1);
return 0;
}
|
output = 4
Why the size of object in case 2 is not 5(int + size of empty class)?
Topic archived. No new replies allowed.