#include<iostream>
using namespace std;
class test
{
public:
//const修饰this指针 即指针所指向的内存空间
//所以this->a,this->b一旦被修改就会报错
void play(int a,int b) const
{
a = 100;//编译没有错误,即const修饰的不是该函数的形参
//this->a = 100;//编译产生错误
//this->b = 200;//产生错误
}
private:
int a;
int b;
};
int main()
{
test t1;
t1.play(1,2);
system("pause");
}
博客围绕C++中const修饰this指针展开,虽未给出具体内容,但可知聚焦于C++这一编程语言里,使用const对this指针进行修饰的相关信息技术知识。
2366

被折叠的 条评论
为什么被折叠?



