this->file = file; 什么意思

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/26 20:18:53
this->file = file; 什么意思

this->file = file; 什么意思
this->file = file; 什么意思

this->file = file; 什么意思
this 指向的事调用该函数的对象,比如
class Test{
    int i, j;
public: 
     void set(int i, int i)
     {
           this->i = i;//将调用该函数的对象中的成员i 赋值为i
           this->j = j;//将调用该函数的对象中的成员j 赋值为j
    }
};
int main()
{
    Test t;
     t.set(10, 20);//set函数中的this就是指向t的指针,相当于this=&t;  
}