mutable.cpp
来自「《C/C++程序员实用大全》配套代码,适用初学C++的人员。」· C++ 代码 · 共 29 行
CPP
29 行
#include <iostream.h>
class Alpha
{
mutable int count;
mutable const int* iptr;
public:
Alpha(void) {count = 0;}
int func1(int i = 0) const { // Promises not to change const arguments.
count = i++; // But count can be changed.
iptr = &i;
cout << "i is: " << *iptr << endl;
return count;
}
void show_count(void) { cout << "Count is: " << count << endl;}
};
void main(void)
{
Alpha a;
a.show_count();
a.func1(10);
a.show_count();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?