Why is the size of an empty class not zero in C++? Please explain the same with examples.
The size of an empty class is not zero. It is 1 byte generally.
See the following example.
The size of an empty class is not zero. It is 1 byte generally.
See the following example.
#include<iostream> using namespace std; class EmptyCls {}; int main () { cout <<”Size of Pointer”<< sizeof (EmptyCls); return 0; }