c++ tips
- 获取结构体中变量在内存中的偏移量
to find out what the offset of this y variable was in memory
#include <iostream>
struct Vector3
{
float x, y, z;
};
int main()
{
int offset = (int)&((Vector3*)nullptr)->y; // 4
std::cout<< offset<< std::endl;
std::cin.get();
}