What is the size of an empty class?

Answer :-
In computer memory is addressed in the form of bytes ever & the minimum memory  is 1 byte. Thats why size of object of empty class is 1 byte.

We can see here-

<br />#include<iostream>
using namespace std;

class Empty {};

int main()
{
cout << sizeof(Empty);
return 0;
}

Output :-
1
Asked by :- Microsoft, Wipro, TATA

Leave a comment