c++ 方法后面加 const

const string getName() const;

前边的const 说明返回的值不能被修改

后边的const 说明该方法只能读取类中的变量,而不能修改类中的变量

posted @ 2014-01-15 22:50  逆游的鱼儿  阅读(859)  评论(0编辑  收藏  举报