/* 常函数: 1.成员函数后加const后我们称这个函数为常函数 2.常函数内不可以修改成员属性 3.成员属性声明时加关键字mutable后,在常函数中依然可以修改
常对象: 1.声明对象前加const称该对象为常对象 2.常对象只能调用常函数 */
#include "pch.h"
#include <iostream>
using namespace std
;
class person {
public:
void showperson() const {
this->m_age
= 100;
this->m_b
= 100;
}
int m_age
;
mutable int m_b
;
};
void test02() {
const person p
;
p
.m_age
= 100;
p
.m_b
= 100;
}
int main()
{
}