The standard does not allow objects (and classes thereof) of size 0, since that would make it possible for two distinct objects to have the same memory address. That’s why even empty classes must have a size of (at least) 1.
More Related Contents:
- sizeof works unusual at c++ after array creation [duplicate]
- Why is the result of sizeof implementation defined? [closed]
- Why isn’t sizeof for a struct equal to the sum of sizeof of each member?
- When a function has a specific-size array parameter, why is it replaced with a pointer?
- Why are C character literals ints instead of chars?
- Is sizeof(bool) defined in the C++ language standard?
- What is the size of a pointer?
- Sizeof string literal
- How does this “size of array” template function work? [duplicate]
- What is the size of void?
- Is sizeof in C++ evaluated at compilation time or run time?
- How do sizeof(arr) / sizeof(arr[0]) work?
- sizeof() a vector
- Does not evaluating the expression to which sizeof is applied make it legal to dereference a null or invalid pointer inside sizeof in C++?
- Can sizeof return 0 (zero)
- Is the size of a struct required to be an exact multiple of the alignment of that struct?
- Why the sizeof(bool) is not defined to be one, by the Standard itself?
- 3-byte int and 5-byte long?
- Why sizeof(int) is not greater than -1? [duplicate]
- sizeof class with int , function, virtual function in C++?
- What does sizeof do?
- Using sizeof on arrays passed as parameters [duplicate]
- Why is −1 > sizeof(int)?
- c++ sizeof(array) return twice the array’s declared length
- sizeof(struct) returns unexpected value
- Can you resize a C++ array after initialization? [duplicate]
- Why sizeof int is wrong, while sizeof(int) is right?
- c++ sizeof() of a class with functions
- How does sizeof know the size of the operand array?
- how to determine sizeof class with virtual functions?