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

Answers were Sorted based on User's Feedback



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

Answer / kundan kumar

1

Is This Answer Correct ?    10 Yes 1 No

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

Answer / 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

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

Answer / rao

2 (if two objects are empty class) otherwise Note : The
size of class = the size of Data members of the objects +
Size of data members of the Class.

Is This Answer Correct ?    0 Yes 2 No

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

Answer / asghar ali chandio

every object will occypy one byte of memory. If objects are
two then Size will be two bytes.

Is This Answer Correct ?    5 Yes 8 No

Post New Answer

More C++ General Interview Questions

How much is size of struct having 1 char & 1 integer?

11 Answers   Persistent,


Given the following function definition: int doit(int &x, int y, int &z) { x = 3*x; y = y + 5; z = x+y; return z - 4; } int a = 5, b = 7, c = 9, d = 11; d = doit(a,b,c);

2 Answers  


Are strings immutable in c++?

0 Answers  


What is the average salary of a c++ programmer?

0 Answers  


What is a reference in C++?

1 Answers  






What are the techniques you use for debugging?

1 Answers   Adtran,


How a modifier is similar to mutator?

0 Answers  


Write a program which uses Command Line Arguments

0 Answers  


Do the parentheses after the type name make a difference with new?

0 Answers  


Why do we need pointers?

0 Answers  


Can we get the value of ios format flags?

0 Answers  


What is do..while loops structure?

0 Answers  


Categories