64,639
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
char a='b';
string b="Microsoft";
class test
{
public:
test(){vpt=&a;vpt2=&b;}
char* vpt;
string* vpt2;
};
void main()
{
test t;
cout<< hex <<(int*)(&t)<<endl;//t的地址
cout<< hex << *(int*)(&t)<<endl; //如何找到t里面的b的地址的?
}
#include <iostream>
using namespace std;
char a='b';
string b="Microsoft";
class test
{
public:
test(){vpt=&a;vpt2=&b;}
char* vpt;
string* vpt2;
};
void main()
{
test t;
cout<< hex <<(int*)(&t)<<endl;//t的地址
cout<< hex << *(int*)((int*)(&t)+1)<<endl; //如何找到t里面的b的地址的?
cout<<hex<<&b<<endl;
system("pause");
}
#include <iostream>
using namespace std;
char a='b';
string b="Microsoft";
class test
{
public:
test(){vpt=&a;vpt2=&b;}
char* vpt;
string* vpt2;
};
int main()
{
printf("%p %p\n",&a,&b);
test t;
cout<< hex <<(int*)(&t)<<endl;//t的地址
cout<< hex << *(int*)(&t)<<endl; //如何找到t里面的b的地址的?
printf("%p %p",t.vpt,t.vpt2);
return 0;
}