注:获取成员变量需要添加this指针.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
// template<typename ToType, typename FromType>
// void GetAddr(ToType &addr, FromType f)
// {
// union
// {
// FromType _f;
// ToType _t;
// }ut;
// ut._f = f;
// addr = ut._t;
// }
//挨个字节显示内存数据
void showByteValue(char *p, int cnt)
{
cout << "挨个字节显示内存数据" << endl;
cout << "===============sizeof(char*)= " << sizeof(char*) << endl;
for (int i = 0;i < cnt; ++i)
{
int *temp = (int*)(p+i);
//cout << (void*)temp << ", " << *(p+i) << endl;
printf("%p: 0x%X, \t%x\n", temp, *(p+i), *temp);
if (i%8 == 7)
printf("\n");