C++之this学习笔记

来源:互联网 发布:dota2网络延迟 编辑:程序博客网 时间:2024/05/21 13:15
*this指当前对象

定义一个成员函数时可以用this代替调用此函数的对象

void CAR :: set (int n, CAR*this)
{
this->set =n
}
此段代码this作为参数使用

还可以返回调用此函数的对象

return this;
return *this;

this就是指向当前对象的指针,
0 0
原创粉丝点击