Last active
May 2, 2016 10:50
-
-
Save cocodrips/82388208de63622ec74973383df65f49 to your computer and use it in GitHub Desktop.
脳みそ整理用
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
#include "stdafx.h" | |
#include <iostream> | |
struct Klass { | |
int value; | |
}; | |
struct Data { | |
int value; | |
Klass *klass; | |
Data () { | |
value = 1; | |
} | |
}; | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
Data *data = new Data(); | |
size_t ptr_size = sizeof(data->klass); // 4 | |
size_t int_size = sizeof(data->value); // 4 | |
size_t data_size = sizeof(*data); // 8 | |
void* address = (void*) &(((Data*)0)->klass); | |
Data* zeroData = (Data*)0; | |
void* offset = (void*) &(zeroData->klass); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment