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 |
What compiler was used?
Explain selection sorting?
What is a flag in c++?
How many lines of code you have written for a single program?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What are the steps in the development cycle?
Define precondition and post-condition to a member function?
Does defining a function inline mean that it wont push and pop things on/off the stack ...like parameters and the return the address??
What is pointer to array in c++?
CAN U SAY WHICH PROGRAMING LANGUAGE IS USED BY DOCTORS....?
What is c++ array?
What is meant by forward referencing and when should it be used?