What is size of empty class object
Answers were Sorted based on User's Feedback
Answer / manish shikarbar
answer is :1
Example:
class Test
{
};
Test Obj;
int size = sizeof(Obj); // answer is 1
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / orvaishnavi
The size of an empty class is 1.
Reason - An object of a class should have unique address.
In order for the object to get unique address, the compiler
inserts a dummy type of size 1(least positive value) into
the empty class so the sizeof the class is returned as 1.
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / vinay singh
the size of class is nothing until it will not create an object. Class is a template so class object size is determined.So here empty class object size is 1 byte and object is created on managed heap.
| Is This Answer Correct ? | 0 Yes | 0 No |
Mention the storage classes in c++.
How many types of scopes are there in c++?
i have given a project to create examination seating plan system in c++. so can anyone send me the answer of this question quickly??????
sizeof- is it functioning statically or dynamically?
What is a syntax in c++?
What is the function of the keyword ‘volatile’ in C++?
Why is the function main() special?
Is arr and &arr are same expression for an array?
Does c++ have string data type?
What is while loops?
advantages and disadvantages of using Borland C++ / version 5.
Can we get the value of ios format flags?