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 |
What flag means?
What is the main purpose of c++?
Difference between static global and global?
16 Answers Microsoft, Symphony, Wipro,
Difference between a homogeneous and a heterogeneous container
founder of c++
7 Answers Microtek, TCS, TeleCommand,
What is a hashmap c++?
How can I learn c++ easily?
Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);
What is the prototype of printf function?
What is iostream in c++ used for?
What is exception handling? Does c++ support exception handling?
what is scupper?