成员函数形参列表后有无const表明this指针是指向常量还是非常量
this指针会传向子函数,也就是说,如果该函数是有const,那么子函数也必须有const,如:
const Screen& display() const
{
do_display();
return *this;
}
void do_display() const
{
cout << content << endl;
}
成员函数形参列表后有无const表明this指针是指向常量还是非常量
this指针会传向子函数,也就是说,如果该函数是有const,那么子函数也必须有const,如:
const Screen& display() const
{
do_display();
return *this;
}
void do_display() const
{
cout << content << endl;
}