class Address {
int i ;
char b;
string c;
public:
void showMap ( void ) ;
};
void Address :: showMap ( void ) {
cout
For the second issue - the compiler by default will pad structure members. The default pad is to the sizeof(int)
, 4 bytes (on most architectures). This is why an int
followed by a char
will take 8 bytes in the structure, so the string
member is at offset 8.
To disable padding, use #pragma pack(x)
, where x is the pad size in bytes.