Re: sizeof empty class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My understanding is that sizeof empty class/struct in C++ is defined
to never be 0 (every object must be addressable, e.g. in cases like
arrays and pointer arithmetic etc. etc.): "no object shall have the
same address in memory as any other variable"

in C(99) standard however, I am under impression but could be wrong,
the sizeof empty struct is undefined (i.e. could be 0):
C99: "If the struct-declaration-list contains no named members, the
behavior is undefined."

anyway -- just my 2 cents.

leon.

On 4/8/10, ranjith kumar <ranjithproxy@xxxxxxxxx> wrote:
> Hi,
>
> 1) What is the size of an an empty class? On my machine it is showing
> 1. What is stored at that 1 byte memory?
> 2) will sizeof() function ever return zero?
> 3)How constructor/destructor are called when an object is created?
>    Any hidden virables will be crerated by the compiler inside the class?
> 4) Why destructor of derived class is not called when we delete a
> baseclass pointer which is pointing to derived class?
>
> Thansk in advance.
>

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux