mutable 关键字

刚才看了一段小程序,发现这个关键字,但是不知道什么作用。
原来是指用此关键字声明的变量是一个易变的变量,即使在const方法中也可以改变类中声明为mutable的属性。
class Screen {
private:
    
    mutable 
int test  ; 
    
    mutable 
int a ;
    
public:
    
int test2() const
    {  
int e = 0 ; ++e ;
    a 
= ++test  + 100 ;  return test ; 
    }
} ;
这是没有问题的
posted @ 2009-10-15 23:13  文生  阅读(534)  评论(0编辑  收藏  举报