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

Explain bubble sorting.

622


What does new return if there is insufficient memory to make your new object?

580


What is a c++ map?

659


How to allocate memory dynamically for a reference?

542


What are vectors used for in c++?

617






What is a namespace in c++?

594


What is the best c++ compiler for windows 10?

576


What does the nocreate and noreplace flag ensure when they are used for opening a file?

676


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

1830


What is runtime polymorphism in c++?

580


What is c++ iterator?

639


What do manipulators do?

564


State the difference between delete and delete[].

572


What is #include cstdlib in c++?

654


Difference between class and structure.

706