*this可用什么替代 c++

如题所述

第1个回答  2014-05-20
voidDate::setMonth(intmn)
{
month=mn;
this->month=mn;
(*this).month=mn;
//这三句是等价的
}

this只能在成员函数中使用。
全局函数,静态函数都不能使用this。
实际上,成员函数默认第一个参数为T*const register this。
相似回答