const函数

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

class test{
public:
    test(){ i_ = 1; }
    int Get() const{
        //i_ = 0; //error:不可以修改
        return i_;
    }
private:
    int i_;
};

 

posted @ 2018-10-24 09:40  BlueOceans  阅读(348)  评论(0编辑  收藏  举报