mutable
1 /* mutable */
2
3 #include<iostream>
4
5 using namespace std;
6
7 class myclass
8 {
9 public:
10 int num;
11 // mutable 声明的变量 不受const 限制 可以在成员函数中修改
12 mutable int data;
13 int getnum() const
14 {
15 data = 1;
16 return this->num;
17 }
18
19 };
20
21 int main()
22 {
23 myclass *p = new myclass;
24 p->getnum();
25
26 std::cin.get();
27 return 0;
28 }
长风破浪会有时,直挂云帆济沧海
posted on 2015-06-04 13:01 Dragon-wuxl 阅读(159) 评论(0) 收藏 举报
浙公网安备 33010602011771号