64,646
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <basetsd.h>
using namespace std;
class Base {
int m_x;
public:
int GetX() {return m_x;}
void SetX(int x) {m_x = x;}
};
class B1 : public Base{
};
int main()
{
B1 *pb1;
pb1->SetX(15);
DWORD_PTR pDW_PTR = (DWORD_PTR)pb1;
Base *pBase = (Base *)pDW_PTR;
int x = pBase->GetX();
return 0;
}
int main(void)
{
B1 b;
B1* pb1 = &b;
pb1->SetX(15);
DWORD_PTR pDW_PTR = (DWORD_PTR)pb1;
Base *pBase = (Base *)pDW_PTR;
int x = pBase->GetX();
return 0;
}