What is size of empty class object

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better turbo c++ or dev c++?

801


Array base access faster or pointer base access is faster?

2082


What is difference between class and function?

840


the maximum length of a character constant can be a) 2 b) 1 c) 8

916


What is meant by entry controlled loop? What all C++ loops are exit controlled?

851


How do you define a class in c++?

858


What new()is different from malloc()?

853


Write about the retrieval of n number of objects during the process of delete[]p?

818


How can I disable the "echo" feature?

868


When are exception objects created?

825


How we can differentiate between a pre and post increment operators during overloading?

872


Differentiate between the manipulator and setf( ) function?

876


What are the types of pointer?

810


Can non graphic characters be used and processed in C++?

947


Why do we use pointers in c++?

802