//this指針問題 2012年7月18日0:37:13
#include <iostream>
using namespace std;
class point
{
public:
int x,y;
point(int a,int b)
{
x= a;
y = b;
}
void input(int x,int y )
{
this->x= x;
this->y =y;
}
void output()
{
cout<<x<<y;
}
};
int main()
{
point a(5,5);
a.input(10,10);
a.output();
return 0;
}
main函數的彙編代碼:
構造函數的彙編代碼:
可以看出通過函數調用__fastcall,寄存器傳值,先將參數保存在臨時變量中,然後通過this指針得到相應的地址,在通過mov指令將數據轉移到內存中去