what is the size of a class which contains no member
variables but has two objects??? is it 1 or 2??

Answer Posted / vasanth

class a
{
};
void main()
{
a obj1;
a obj2;
cout<<"sizeof class = "<<sizeof(a)<<endl<<"sixeof
obj1 = "<<sizeof(obj1)<<endl<<"sixeof obj2 = "<<sizeof(obj2)
<<endl;
}
--------------------
always sizeof the empty class is 1 byte and each object it
will tak 1 byte.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write about all the implicit member functions of a class?

608


What is the use of dot in c++?

639


Is c++ the hardest language?

575


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

1466


List down the guideline that should be followed while using friend function.

655






What are the differences between malloc() and calloc()?

619


How can you specify a class in C++?

812


How many namespaces are there in c++?

566


How a new element can be added or pushed in a stack?

590


What are maps in c++?

514


How can a called function determine the number of arguments that have been passed to it?

673


What are the differences between the function prototype and the function defi-nition?

629


What is a pdb file?

548


How do I start a c++ project?

598


What is runtime errors c++?

585