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 are compilers in c++?
State the difference between delete and delete[].
What is object file? How can you access object file?
Differentiate between a constructor and a method in C++.
Write a single instruction that will find the remainder of integral division when x is divided by y. Have the answer stored in z.
In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....
0 Answers College School Exams Tests, CS,
What is the best c++ compiler for windows 10?
diff between pointer and reference in c++?
Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL
What is a constructor in c++ with example?
Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?
What is protected inheritance?