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

When should we use container classes instead of arrays?

584


Which is the best c++ software?

609


What is difference between array and vector in c++?

559


What is the limitation of cin while taking input for character array?

1455


Write a c program for binary addition of two 8 bit numbers.

3668






What is pure virtual function?

632


What is c++ flowchart?

678


Is c++ fully object oriented?

553


What is the error in the code below and how should it be corrected?

307


Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02

1512


Differentiate between a template class and class template in c++?

635


Are strings immutable in c++?

657


Can the creation of operator** is allowed to perform the to-the-power-of operations?

582


What are the defining traits of an object-oriented language?

694


What is an undefined reference/unresolved external symbol error and how do I fix it?

603