this指针的作用

    xiaoxiao2021-03-26  19

    //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指令将数据转移到内存中去

    转载请注明原文地址: https://ju.6miu.com/read-659300.html

    最新回复(0)