why the size of an empty class is 1

Answer Posted / hitesh sojitra

When you calculate the size of a empty class that time you can c it takes 1 byte.which is the size of a char which a compiler takes for storing the address of a empty class.

The size of an empty class would depend on what is the range specified for the compiler for char. It takes that much space to store the address of a class.

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do we balance an AVL Tree in C++?

733


Explain the static member function.

815


What is object in c++ wikipedia?

645


Is sorted c++?

680


Describe the process of creation and destruction of a derived class object?

740






Difference between declaration and definition of a variable.

711


Define a constructor - what it is and how it might be called (2 methods)?

696


How can you quickly find the number of elements stored in a static array?

729


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

711


Why do we need runtime polymorphism in c++?

646


What is a base class?

694


What are the advantages of using const reference arguments in a function?

706


What are the advantages of using a pointer?

693


Why was c++ created?

653


What is the best it certification?

702