关于运行时不可变类
以下面的类为例:
class MyClass {
private:
int call_count = 0;
public:
int a = 1;
const int b = 2;
int *c = nullptr;
const int *d = nullptr;
// 假设我们实现了许多逻辑
public:
auto const_func() const -> bool {
call_count++;
return false; // 假设这边的值是计算出来的
}
auto func() -> bool {
call_count++;
return false; // 假设这边的值是计算出来的
}
};