后端开发
常量成员函数 标签描述

文章目录 一、常量成员函数 1、const修饰成员函数分析 2、常量成员函数 3、错误代码示例常量成员函数修改成员变量 二、完整代码示例 一、常量成员函数 1、const修饰成员函数分析 在C类中,普通的非静态成员函数,可以使用const进行修饰, 在下面的Student类中,定义了voidfun(intage,intheight)成员函数,下面使用const关键字修饰该类; 使用const修饰成员函数,写法如下,在fun()之后使用const关键字修饰函数: voidfun(intage,intheight)const const修饰的是fu...