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

Is map thread safe c++?

741


What is problem with overriding functions?

676


Will rust take over c++?

684


What is the use of map in c++?

723


Specify different types of decision control statements?

466






How do you save a c++ program?

659


Define a constructor?

688


Do you know what is overriding?

691


Describe the syntax of single inheritance in C++?

737


Explain virtual destructor?

800


How static variables and local variablesare similar and dissimilar?

664


A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.

3517


Can you explicitly call a destructor on a local variable?

673


Define pre-condition and post-condition to a member function in c++?

761


What is the difference between a definition and a declaration?

662