const in C++

来源:互联网 发布:淘宝登录界面刷不出来 编辑:程序博客网 时间:2024/06/07 10:10

Contents below mainly come fromhere

consts in this declaration:

// v───v───v───v───v───v───v───v───v───v───v───v─┬┐//                                               ││//  v──#1    v─#2             v──#3    v─#4      #5   int const * const Method3(int const * const&) const
#5 means that this function must be a member function of a class, and the object which calls this function can not be modified through this call.
#4 means that the pointer is const. That is to say, the pointer can not point to another address.
#3 means that the int is const that it can not have a different value.
#2 means  that this function returns a const pointer, like #4.
#1 means that this function returns a const int, like #3.


原创粉丝点击