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

Explain the difference between using macro and inline functions?

686


What is binary search in c++?

684


what are the iterator and generic algorithms.

1571


What is setw manipulator in c++?

700


What is the use of typedef?

732






Who discovered c++?

656


How can I disable the "echo" feature?

696


What are virtual functions in c++?

785


What is the standard template library (stl)?

729


What is a tree in c++?

637


Write a program to show polymorphism in C++?

725


What are features of c++?

742


what does the following statement mean? int (*a)[4]

701


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6007


What is class definition in c++ ?

726