摘要:
c++中通过把类成员函数声明为const类型,表明他们不修改类对象。 Class::fun() const; 任何不修改成员变量的函数都应该这样写。如果const修饰的成员函数修改了类对象,编译器报错。 阅读全文
posted @ 2019-09-06 17:19
izrial
阅读(2188)
评论(0)
推荐(1)
摘要:
int fun(int x);//在c++中尽量不要这么写, int fun(const int & x);//这种写法,前提是x不能被修改,使用引用提高效率。 阅读全文
posted @ 2019-09-06 16:06
izrial
阅读(2071)
评论(1)
推荐(0)

浙公网安备 33010602011771号