I think it very easy but it makes me confused
Code:
struct Fileheader
{
unsigned short Type; // BM Identifier
unsigned long Size; // total length in bytes
unsigned short Reserved1; // image id or revision
unsigned short Reserved2;
unsigned long OffBits;// offset to start of actual pixel data
Fileheader()
{
Reserved1=0;
Reserved2=0;
}
};
int main()
{
cout<<sizeof(Fileheader)<<endl;
}
The Output is 16 <---2+4+2+2+4=??
I can't believe so I check again
Code:
struct Fileheader
{
unsigned short Type; // BM Identifier
unsigned short Size; // total length in bytes
unsigned short Reserved1; // image id or revision
unsigned short Reserved2;
unsigned long OffBits;// offset to start of actual pixel data
Fileheader()
{
Reserved1=0;
Reserved2=0;
}
};
int main()
{
cout<<sizeof(Fileheader)<<endl;
}
The output is 12=2+2+2+2+4...accurate but
So it means that we can't have a struct having size of 14??