1. 程式人生 > >this 指標的地址--呼叫成員函式的所在物件的起始地址

this 指標的地址--呼叫成員函式的所在物件的起始地址

#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
請按任意鍵繼續. . .