#include <cstddef> // 包含 offsetof 宏
#include <iostream>
struct MyStruct {
int a;
double b;
char c;
};
int main() {
// 计算成员 'a' 的偏移量
std::cout << "Offset of 'a': " << offsetof(MyStruct, a) << std::endl;
// 计算成员 'b' 的偏移量
std::cout << "Offset of 'b': " << offsetof(MyStruct, b) << std::endl;
// 计算成员 'c' 的偏移量
std::cout << "Offset of 'c': " << offsetof(MyStruct, c) << std::endl;
return 0;
}