Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2006

Tip: Looking for answers? Try searching our database.

Size of an empty class.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Harish - 15 Jun 2006 10:25 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?
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"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.