This was an interview question: The size of an empty class is 1 byte. Why?
Should it not be 4 bytes? Because an invisible pointer "this" is part of
every class?
Jeff Partch - 15 Jun 2006 10:46 GMT
> This was an interview question: The size of an empty class is 1 byte. Why?
> Should it not be 4 bytes? Because an invisible pointer "this" is part of
> every class?
The this pointer is not part of the class it is the address of the class
instance. The sizeof an empty object is 1 so that each instance will have a
unique address.

Signature
Jeff Partch [VC++ MVP]
Bruno van Dooren - 15 Jun 2006 11:07 GMT
> This was an interview question: The size of an empty class is 1 byte. Why?
> Should it not be 4 bytes? Because an invisible pointer "this" is part of
> every class?
There was an extensive discussion about this topic last month in the thread
'Question about sizeof a class.'
google archive:
http://groups.google.be/group/microsoft.public.dotnet.languages.vc/browse_thread
/thread/dbee14b6c46bc898/3c74822ed72091bc?lnk=st&q=Question+about+sizeof+a+class
.&rnum=1&hl=nl#3c74822ed72091bc

Signature
Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"