Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Size of an empty class why 1 byte ?

Reply
Thread Tools

Size of an empty class why 1 byte ?

 
 
Sweety
Guest
Posts: n/a
 
      08-20-2004
hello,
why sizeof an empty class why 1 byte ?

plz illustrate this ?
bye
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-20-2004
Sweety wrote:
> why sizeof an empty class why 1 byte ?


Because if it weren't there would be no way to
distinguish between different objects in an array.

V
 
Reply With Quote
 
 
 
 
rossum
Guest
Posts: n/a
 
      08-20-2004
On 20 Aug 2004 12:56:34 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (Sweety)
wrote:

>hello,
> why sizeof an empty class why 1 byte ?
>
>plz illustrate this ?
>bye


Everything must have a different address in memory, otherwise there
are big possibilities for confusion with pointers, references and
suchlike. Hence even an empty class takes up one byte so the next
thing you declare will have a different address.

rossum

--

The ultimate truth is that there is no Ultimate Truth
 
Reply With Quote
 
DaKoadMunky
Guest
Posts: n/a
 
 
Reply With Quote
 
rossum
Guest
Posts: n/a
 
      08-21-2004
On 21 Aug 2004 01:00:41 GMT, (E-Mail Removed) (DaKoadMunky) wrote:

>http://www.research.att.com/~bs/bs_f...l#sizeof-empty


[mode = modesty NOT]Nice to see that Bjarne agrees with me.[/mode]

rossum

--

The ultimate truth is that there is no Ultimate Truth
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Why empty class size is 1 Byte ??? John Carson C++ 10 04-18-2010 11:40 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why is size of object of empty class is 1 byte ishekara C++ 8 01-05-2005 10:03 PM
Re: Why empty class size is 1 Byte ??? raghav C++ 0 07-07-2003 10:44 AM
Re: Why empty class size is 1 Byte ??? Alexander Terekhov C++ 0 07-07-2003 08:47 AM



Advertisments