Const Is Not Deep
class Cache {
mutable int hits_ = 0;
int value_ = 7;
int* ptr_ = &value_;
public:
int get() const {
++hits_; // (1)
*ptr_ = 99; // (2)
ptr_ = nullptr; // (3)
return value_;
}
};
Which of (1), (2) and (3) compile?
Sign in to answer questions and track your progress
Sign In