const member function不明白

来源:互联网 发布:增加字段的sql语句 编辑:程序博客网 时间:2024/05/18 12:03

 class中,成员函数 const string& GetName()const{ return  name}

第一个const与第二个const。。。不明白。我的理解:
第一个const,返回值为常量值。
第二个const,表明在该成员函数中不可以改变成员变量的值。(是不是就是认为成员变量为常量?象上面的函数返回值是不是就只能为const string,而不能为string?)

 

原创粉丝点击