What is size of empty class object

Answers were Sorted based on User's Feedback



What is size of empty class object..

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

What is size of empty class object..

Answer / kaminee

1

Is This Answer Correct ?    9 Yes 3 No

What is size of empty class object..

Answer / shanky

ans-1.

Is This Answer Correct ?    6 Yes 0 No

What is size of empty class object..

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

What is size of empty class object..

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

Post New Answer

More C++ General Interview Questions

How the delete operator differs from the delete[]operator?

0 Answers  


To which numbering system can the binary number 1101100100111100 be easily converted to?

0 Answers  


When can you tell that a memory leak will occur?

1 Answers  


What are the differences between java and c++?

0 Answers  


What are stacks?

0 Answers  






Difference between Operator overloading and Functional overloading?

10 Answers   HP,


write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1

5 Answers  


program explaining feautures of c++

0 Answers   Satyam,


What is code reusability in c++?

0 Answers  


Which is best c++ or java?

0 Answers  


What is the difference between a baller and a reference in C++?

0 Answers  


Explain how a pointer to function can be declared in C++?

0 Answers  


Categories