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

write a C++ programming using for loop: * * * * * * * * * *

4 Answers   TCS,


Should the member functions which are made public in the base class be hidden?

0 Answers  


Which function should be used to free the memory allocated by calloc()?

0 Answers  


What is data abstraction? How is it different from data encapsulation?

0 Answers  


When to use Multiple Inheritance?

6 Answers  






What are the steps in the development cycle?

0 Answers  


Describe protected access specifiers?

0 Answers  


Can user-defined object be declared as static data member of another class?

0 Answers  


What are arrays c++?

0 Answers  


What problem does the namespace feature solve?

1 Answers  


Can a constructor return a value?

0 Answers  


What is switch case in c++ syntax?

0 Answers  


Categories