What is size of Empty Class?

Answers were Sorted based on User's Feedback



What is size of Empty Class?..

Answer / rahul

1 Byte. Class is static entity.

Is This Answer Correct ?    17 Yes 1 No

What is size of Empty Class?..

Answer / 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

What is size of Empty Class?..

Answer / saket kale

when i tried to calculate the size of an empty class that
time i found that it takes 1 byte.which is the size of a
char.That might be the memory taken by the compiler for
storing the address of a empty class.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is the difference between function overloading and operator overloading?

0 Answers  


What is math h in c++?

0 Answers  


What are the advantages of using a pointer?

0 Answers  


What does extern mean in a function declaration in c++?

0 Answers  


How to give an alternate name to a namespace?

0 Answers  






What are raw sockets, where they are efficient?

2 Answers   Symphony,


What is operators in c++?

0 Answers  


State two differences between C and C++.

0 Answers   Hexaware,


If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?

0 Answers  


Describe run-time type identification?

1 Answers  


What does #define mean in c++?

0 Answers  


Describe private, protected and public?

0 Answers  


Categories