Size of empty class

This code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

class Foo
{

};

int main()
{
    Foo foo;
    std::cout << sizeof ( foo ) << std::endl;

    std::cin.get();
    return ( 0 );
}

produces this result:

1


Why is the size of an instance of Foo 1, although it doesn't have any member variables?
Objects have identity; each object must have a unique address in memory.

For instance, these eleven objects must be distinguishable from each other:
1
2
Foo bar[10] ;
Foo baz ;
Last edited on
Ah, that makes sense. Thanks!
Topic archived. No new replies allowed.