Size of an empty class why 1 byte ?

Discussion in 'C++' started by Sweety, Aug 20, 2004.

  1. Sweety

    Sweety Guest

    hello,
    why sizeof an empty class why 1 byte ?

    plz illustrate this ?
    bye
    Sweety, Aug 20, 2004
    #1
    1. Advertising

  2. 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
    Victor Bazarov, Aug 20, 2004
    #2
    1. Advertising

  3. Sweety

    rossum Guest

    On 20 Aug 2004 12:56:34 -0700, (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
    rossum, Aug 20, 2004
    #3
  4. Sweety

    DaKoadMunky Guest

  5. Sweety

    rossum Guest

    rossum, Aug 21, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Carson
    Replies:
    10
    Views:
    20,830
    cplusprog
    Apr 18, 2010
  2. Alexander Terekhov

    Re: Why empty class size is 1 Byte ???

    Alexander Terekhov, Jul 7, 2003, in forum: C++
    Replies:
    0
    Views:
    409
    Alexander Terekhov
    Jul 7, 2003
  3. raghav
    Replies:
    0
    Views:
    651
    raghav
    Jul 7, 2003
  4. ishekara
    Replies:
    8
    Views:
    10,707
    Mike Wahler
    Jan 5, 2005
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,744
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page