What is the difference in size of this two clasees?
Class A
{
int a;
char c;
float f;
}
Class B
{
float f;
char c;
int a;
}

Answers were Sorted based on User's Feedback



What is the difference in size of this two clasees? Class A { int a; char c; float f; } Class..

Answer / truong nguyen

1. No difference in size in this case. There will be
difference in size, however, if the class A and B are
defined below:

Class A
{
int a;
double d;
char c;
}
Class B
{
double d;
char c;
int a;
}

Is This Answer Correct ?    3 Yes 0 No

What is the difference in size of this two clasees? Class A { int a; char c; float f; } Class..

Answer / som shekhar

No difference

Is This Answer Correct ?    3 Yes 2 No

What is the difference in size of this two clasees? Class A { int a; char c; float f; } Class..

Answer / som shekhar

well there will be no difference..define the macro
#pragma pack(1) and then calculate the size of the class....

Actually compiler aligns the boundary to the nearest larger
byte. If you define the aforementioned macro, compiler will
give you the exact size of the class.

Hope that is clear.

Is This Answer Correct ?    1 Yes 0 No

What is the difference in size of this two clasees? Class A { int a; char c; float f; } Class..

Answer / nisha

no difference

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Do you know what are static and dynamic type checking?

0 Answers  


What is the basic structure of c++ program?

0 Answers  


How long it will take to learn c++?

0 Answers  


What is difference between class and function?

0 Answers  


What is the size of a vector?

0 Answers  






what is COPY CONSTRUCTOR and what is it used for?

0 Answers  


What are maps in c++?

0 Answers  


Explain how the virtual base class is different from the conventional base classes of the opps.

0 Answers  


What is a c++ map?

0 Answers  


Difference between overloaded functions and overridden functions

0 Answers  


Define friend function.

0 Answers  


Explain the ISA and HASA class relationships. How would you implement each in a class design?

3 Answers  


Categories