I just tried to check how memory is allocated to structure objects, its taking more space what i expected. I am using 64 bit windows OS and Microsoft visual studio 2010(i think its 32 bit), so can some explain why is its printing 52 bytes ?
struct test {
int year;// should take 4 byte
string title;// how much bytes would take ? in my case taking 31 bytes ?
double date;//should take 8 byte
int month;// should take 4 byte
} mine;
int main ()
{
cout << " size is: "<<sizeof(mine);//printing 52 ?
cout << " size is: "<<sizeof(struct test);//printing 52 ?
return 0;
}