mutable mutable:表示即使在const对象中,也可以修改此成员 class student { int id; mutable int age;//mutable表示即使在const函数中也可以修改 public: int get_id() const { //id = id +1;错误 return id; } int get_age() const { age = age + 1; return age; } };