I have two calsses
class Date
{
short year;
char month;
char day;
}
class DateTime : Date
{
char hour;
char minute;
char second;
int millisecond;
}
where char is 1 byte, short is 2 bytes, and int is 4 bytes
I was assuming that sizeof(DateTime) would then be 11 bytes...but when I actually called sizeof(DateTime) I got 12 bytes!!
Is there a 1 byte overhead for inherited classes?
A sizeof(Date) is 4...therefore 8 other bytes are in DateTime where is only look like it should be contributing 7
class Date
{
short year;
char month;
char day;
}
class DateTime : Date
{
char hour;
char minute;
char second;
int millisecond;
}
where char is 1 byte, short is 2 bytes, and int is 4 bytes
I was assuming that sizeof(DateTime) would then be 11 bytes...but when I actually called sizeof(DateTime) I got 12 bytes!!
Is there a 1 byte overhead for inherited classes?
A sizeof(Date) is 4...therefore 8 other bytes are in DateTime where is only look like it should be contributing 7