您的位置:首页 > 其它

this 指针的地址--调用成员函数的所在对象的起始地址

2016-10-02 11:54 351 查看
#include<iostream>
using namespace std;
class Test
{
int x;
public:
Test(int a){
x=a;
}
void get_this();
};
void Test:: get_this()
{
cout<<"this points to"<<this<<endl;
}
int main()
{
Test obj(12);
cout<<"obj address:"<<&obj<<endl;
obj.get_this();
}
obj address:0x23fe40

this points to0x23fe40

--------------------------------

Process exited after 3.464 seconds with return value 0

请按任意键继续. . .
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐