Skip to content

Instantly share code, notes, and snippets.

@thiagomg
Created November 23, 2015 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagomg/c1ec3ac4d55865bcab09 to your computer and use it in GitHub Desktop.
Save thiagomg/c1ec3ac4d55865bcab09 to your computer and use it in GitHub Desktop.
Layout de memória de structs e classes
//16B
struct message {
int x; //4B
int y; //4B
int z; //4B
int w; //4B
};
//16B
struct pack1 {
message m1;
};
//16 + 8 + 8
struct pack2 {
message m1;
message *m2;
message &m3;
};
std::cout << sizeof(pack1) << std::endl; //16
std::cout << sizeof(pack2) << std::endl; //32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment