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
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 |
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 |
Does there exist any other function which can be used to convert an integer or a float to a string?
What is abstract keyword in c++?
What happens if a pointer is deleted twice?
Refer to a name of class or function that is defined within a namespace?
Which programming language should I learn first?
Show the application of a dynamic array with the help of an example.
Can you pass an array to a function in c++?
What is an accessor in c++?
How do you initialize a class member, class x { const int i; };
What's the hardest coding language?
What is difference between rand () and srand ()?
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;