先看有无修改类成员变量的接口(函数),通过接口(函数)进行修改。
再看是否已知类的结构(成员变量的类型)(必须考虑内存对齐)->可以通过指针进行修改
class Ctest
{
int a;
float b;
}
Ctest test;
int* pa=&test;
*pa=50;
float *pb=(float*)((int)&test + sizeof(int))
*pb=100.0f;
转载于:https://blog.51cto.com/10739786/1747856