const成员函数与const对象
来源:互联网 发布:义乌美工培训学校排名 编辑:程序博客网 时间:2024/05/16 07:21
const成员函数与const对象:
const成员函数作用于this指针,被声明为常量的成员函数,其this指针为一个常量指针,因此成员函数中无法修改成员变量,也无法调用其它非常量型成员函数。
(常量型成员函数可以和非常量型成员函数构成重载关系,重载匹配关系由调用对象常属性决定。常对象/常引用/只能调用常量型成员函数,非常量/非引用/非指针优先调用非常量型成员函数,如果没有非常量型版本,则调用常量型版本)
不过省声明为mutable的成员变量可以在常量型成员函数中被修改。
声明:
void const_fun() cosnt;
定义:
void class::cosnt_fun() const {}
0 0
- const成员函数与const对象
- const对象与const成员函数
- const成员函数与const对象
- const对象const成员函数
- c++中const对象与const成员函数
- C++杂记:const对象与const成员函数
- c++中const 对象与const 成员函数
- C++中const对象与const成员函数
- c++中 const 对象与 const 成员函数
- c++中 const 对象与 const 成员函数
- const对象与const函数
- const对象调用非const成员函数
- const对象和const成员函数
- const对象和const成员函数
- const对象,const成员函数总结
- const对象和const成员函数
- const修饰成员函数const修饰对象
- const 对象和 const 成员函数
- SWTableViewCell
- SQL Server 2012 各版本功能比较
- ECShop——删除ECSHOP2.7.3后台左侧菜单中的云服务中心
- 程序员技术练级攻略
- UVA 11183 Teen Girl Squad (最小树形图)
- const成员函数与const对象
- iOS 7 教程:定制iOS 7中的导航栏和状态栏
- mybatis3.x 插入返回主键
- 改变TextView中部分字体颜色
- yaf
- 笔试面试7 如何判断一个系统的存储方式是大端还是小端
- 重点介绍了复制构造函数, 直接初始化,复制初始化,赋值,临时对象之间的关系,本文内容全面,简单易懂
- 百度装机CentOS链接
- hdu1595(spfa) find the longest of the shortest