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

Are iterators pointers?

0 Answers  


What are the advantages of C++ programming compared to C programming?

2 Answers   HAL,


Differences between private, protected and public and give examples.

0 Answers  


Do vectors start at 0?

0 Answers  


What is nested class in c++?

0 Answers  






Write a C++ program that asks the user to choose a number between 1 and 1000. Then, your program should be able to guess the number by asking the user no more than 10 yes/no questions. Use a while loop in your program

1 Answers  


How compile and run c++ program in turbo c++?

0 Answers  


Using a smart pointer can we iterate through a container?

0 Answers  


Why struct is used in c++?

0 Answers  


Which sort is best for the set: 1 2 3 5 4 a) Quick Sort b) Bubble Sort c) Merge Sort

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

4 Answers   Webyog,


i have given a project to create examination seating plan system in c++. so can anyone send me the answer of this question quickly??????

1 Answers  


Categories