Behaviour of sizeof in VC++.NET !
I have a concern about sizeof behaviour in VC++.NET. By reading the MSDN documentation I came to know that in creating classes and structs some padding is done in allocating space to members. So when I will get the sizeof following class
class MyClass
{
char _mcData;
long _mlData;
double _mdData;
};
by using cout << sizeof(MyClass);
I will get 16 which is the sizeof this class after padding. By experimenting in different scenarios I came to know that the padding is done in multiples of the largest type in the class or struct. My concern is why is such a need of padding or if there is really some reason to do this what might be the reason, if any one knows please tell me.
Regards,
Haroon Saeed

