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

Does there exist any other function which can be used to convert an integer or a float to a string?

0 Answers  


What is abstract keyword in c++?

0 Answers  


What happens if a pointer is deleted twice?

0 Answers   Flextronics,


Refer to a name of class or function that is defined within a namespace?

0 Answers  


Which programming language should I learn first?

0 Answers  






Show the application of a dynamic array with the help of an example.

0 Answers  


Can you pass an array to a function in c++?

0 Answers  


What is an accessor in c++?

0 Answers  


How do you initialize a class member, class x { const int i; };

8 Answers   emc2,


What's the hardest coding language?

0 Answers  


What is difference between rand () and srand ()?

0 Answers  


What is the output of: String a1 = "Hello"; String a2 = "world!"; String* s1 = &a2; String& s2 = a1; s1 = &a1; s2 = a2; std::cout << *s1 << " " << s2 << std::endl;

4 Answers   Lehman Brothers,


Categories