Created
November 23, 2015 01:57
-
-
Save thiagomg/c1ec3ac4d55865bcab09 to your computer and use it in GitHub Desktop.
Layout de memória de structs e classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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