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

Search for: what is pair in c++?

586


What is std :: endl?

593


Write a code/algo to find the frequency of each element in an array?

599


what is multi-threading in C++?

611


Where are setjmp and longjmp used in c++?

610






What is data abstraction? How is it different from data encapsulation?

529


How can I learn dev c++ programming?

563


the first character in the variable name must be an a) special symbol b) number c) alphabet

599


Distinguish between a # include and #define.

643


Is atoi safe?

591


Incase of a function declaration, what is extern means?

513


Can we use this pointer inside static member function?

621


Is there finally in c++?

617


How should a contructor handle a failure?

682


Const char *p , char const *p What is the difference between the above two?

656