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 is the difference between while and do while loop?

884


Explain how overloading takes place in c++?

787


What is an undefined reference/unresolved external symbol error and how do I fix it?

880


Which software is used to run c++ program?

763


Explain the difference between new() and malloc() in c++?

881


Explain some examples of operator overloading?

885


What is constructor c++?

899


what is VOID?

854


When can I use a forward declaration?

847


Explain pass by value and pass by reference.

829


How do I start a c++ project?

816


What methods can be overridden in java?

977


What is the most useful programming language?

842


What are separators in c++?

854


What are references in c++?

909