#include <iostream>
struct Entity {
int x, y;
};
int main() {
Entity e = {5, 8};
int x = *(int*)&e;
std::cout << x << std::endl;
std::cin.get();
}
输出:5
#include <iostream>
struct Entity {
int x, y;
};
int main() {
Entity e = {5, 8};
int y = *(int*)((char*)&e+4);
std::cout << y << std::endl;
std::cin.get();
}
输出:8