top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to determine size of a class in C++ ?

+4 votes
How to determine size of a class in C++ ?
posted Oct 18, 2014 by Harshita

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

If I understood your query correctly, your concern is about size of an empty class.
Size of an empty class is 1 byte. It is because if you create two objects of an empty class, there should be at least one byte difference between their addresses. Reason being, sizeof an empty class is not kept as zero.

answer Oct 20, 2014 by Ganesh
Similar Questions
+2 votes

Below is the sample code, Where size of a is not defined at the time of compilation,
Then how compiler knows the size of a? If we run the same program in C then compilation will fail.

using namespace std;
        string a;
+6 votes
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.