const函数

1. const修饰成员函数:表示不可以修改成员变量

class test{
public:
    test(){ i_ = 1; }
    int Get() const{
        //i_ = 0; //error:不可以修改
        return i_;
    }
private:
    int i_;
};
原文地址:https://www.cnblogs.com/haiyang21/p/9841767.html