Correct option is B
In C++, an empty class has a default size of
1 byte to ensure that each object of the class has a unique memory address, even if it contains no data members.
Important Key Points:
1. The size of an empty class ensures that objects of the class can be distinguished in memory.
2. Adding even one non-static member increases the size beyond 1 byte.
3. Static members do not contribute to the size of an object because they are shared across all instances.
Knowledge Booster:
·
Empty Class Size in Java: In Java, objects of empty classes are not explicitly stored, as they are treated differently.
·
Padding in C++: The compiler may add padding for alignment if other members are introduced later.