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

How would you implement a substr() function that extracts a sub string from a given string?

0 Answers  


What are stacks? Give an example where they are useful.

0 Answers  


What is the last index number in an array of 100 characters a) 100 b) 99 c) 101

0 Answers  


What is a unnitialised pointer?

0 Answers  


What are virtual functions and what is its use?

1 Answers  


What are namespaces in c++?

0 Answers  


Evaulate: 22%5 a) 2 b) 4 c) 0

0 Answers  


Define a constructor - what it is and how it might be called (2 methods)?

0 Answers  


When there is a global variable and local variable with the same name, how will you access the global variable?

0 Answers  


Is c++ a dying language?

0 Answers  


Differentiate between late binding and early binding. What are the advantages of early binding?

0 Answers  


int *p = NULL; printf("%1d",p) ; what will be the output of this above code?

3 Answers   Microsoft,


Categories