What is size of Empty Class?

Answer Posted / amit basak

The size of the class will be 1 byte as mentioned by Rahul...
Here is the below code in Cygwin ...

// This program is to find the size of empty class

#include<iostream>

using namespace std;

class Demo
{

};

int main ()
{
cout <<"Sizeof Demo class is ="<<sizeof(Demo)<<endl;

return(0);
}


And here is the output..
$ ./a.exe
Sizeof Demo class is =1

Is This Answer Correct ?    14 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What you know about structures in C++?

823


What is meant by entry controlled loop? What all C++ loops are exit controlled?

836


Mention the storage classes in c++.

844


What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required

795


What is the difference between struct and class?

1064


Explain the difference between realloc() and free() in c++?

755


How many standards of c++ are there?

858


How to allocate memory dynamically for a reference?

797


What is c++ virtual inheritance?

837


Explain the difference between c++ and java.

866


What does std mean in c++?

804


Explain how the virtual base class is different from the conventional base classes of the opps.

910


Explain method of creating object in C++ ?

813


What do you understand by zombie objects in c++?

829


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

868