Click to See Complete Forum and Search --> : off set in structure or class size.


engrsanjiv
June 2nd, 2003, 04:10 PM
How the off set are set while allocating memory.
calss A()
{
public:
char a[10];
char b[2];
float c;
};


calss B()
{
public:
char a[10];
float c;
char b[2];
};

int aa=sizeof(A)// returns 16 bytes
int aa=sizeof(B)// returns 20 bytes

how the offsets are defined in structure and classes.

Thanks.

Graham
June 2nd, 2003, 04:18 PM
It's dependent on the compiler that you use. It's rarely relevant, anyway.

mwilliamson
June 2nd, 2003, 05:24 PM
Its configured by the "struct member alignment" settings. Search for this topic if you need more information.

engrsanjiv
June 3rd, 2003, 11:21 AM
Thanks mwilliamson
I got it .