adspace


what is the size of this class
class size
{
public:
char data1;
double d;
int data2;
char data3;
double data4;
short data5;
};

please explain the padding for these double variables.

Answer Posted / ada

I tried sizeof() the class and the output is 40 bytes. I
think the padding maybe like this:

char data1 1+7 bytes
double d 8 bytes
int data2 4 bytes char data3 1+3 bytes
double data4 8 bytes
short data5 2+6 bytes

So totally 5x8=40 bytes

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can union be self referenced?

1279


What character terminates all character array strings a) b) . c) END

1403


What is the latest version on c++?

1217


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1172


daily Routine of father

1492