Friday, December 3, 2010

Class Size

class A {}; is 1 byte on Solaris.

The size needs to be at least one byte, so that a reference can be declared using an object of the class. For example: ...; A a; A& ra = &a; ... This is the same value given in Microsoft


Note that the size is still one even when the 'struct' keyword is used instead of the 'class' keyword. Also note, in C, the size of an empty struct is 0 and not 1 as in C++. This is

because there are no references in C.

No comments:

Post a Comment