Possible Duplicate:
C++: What is the size of an object of an empty class?
#include <iostream>
class C
{
};
int main()
{
std::cout << sizeof(C) << std::endl;
return 0;
}
output: 1
Why 1, but not zero ?
Possible Duplicate:
C++: What is the size of an object of an empty class?
#include <iostream>
class C
{
};
int main()
{
std::cout << sizeof(C) << std::endl;
return 0;
}
output: 1
Why 1, but not zero ?
The c++ standard says that every class/struct must have at least 1 byte.
Because the C++ standard requires all objects to have a nonzero size. This helps ensure that every object has a unique address.