What is size of Empty Class?
Answers were Sorted based on User's Feedback
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 |
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 |
Is python better than c++?
Why is polymorphism useful?
What is enum class in c++?
What is the use of ‘using’ declaration?
What are the restrictions apply to constructors and destructors?
What does return 0 do in c++?
In which memory a class gets stored(in heap /in stack)? And why??
Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?
Incase of a function declaration, what is extern means?
What is decltype c++?
Are vectors faster than arrays?
how can u create a doubly linked list with out using pointers?