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 c++ best used for?

0 Answers  


Can you explain the term "resource acquisition is initialization?"

1 Answers   Amazon,


What is encapsulation in c++?

0 Answers  


What is the difference between equal to (==) and assignment operator (=)?

0 Answers  


Which programming language's unsatisfactory performance led to the discovery of c++?

0 Answers  






Can we change the basic meaning of an operator in c++?

0 Answers  


What is flush () in c++?

0 Answers  


write a c++ program that gives output 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 using looping statement

2 Answers  


Declare a class vehicle and make it an abstract data type.

0 Answers  


If I is an integer variable, which is faster ++i or i++?

0 Answers  


What is an object in c++?

0 Answers  


Can you sort a set c++?

0 Answers  


Categories