What is data structure padding in c++ and how do i check the number of bytes padded bytes?
class a { public: int x; int y; int z; };
Processors require that certain types of data have particular alignments. For example, a processor might require that an int be on a 4-byte boundary. So, for example, an int could start at memory location 0x4000 but it could not start at 0x4001. So if you defined a class:
class a
{
public:
char c;
int i;
};
the compiler would have to insert padding between c and i so that i could start on a 4-byte boundary.