Post by thomasstruct A{
int a;
char b;
};
class B{
int a;
char b;
};
sizeof(A)=6; sizeof(B)=8. why?
This program prints "8 8" with my copy of VC8:
#include "stdio.h"
struct A{
int a;
char b;
};
class B{
int a;
char b;
};
int main() {
printf("%d %d\n", sizeof(A), sizeof(B));
return 0;
}
I could get it to print "6 6" with #pragma pack or by using /Zp2 compiler switch. The only way I could get it to print different numbers is by putting #pragma pack between two class declarations - but that's cheating.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925