Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Can you change state in a const function in C++? Why? How? | Better HN
Can you change state in a const function in C++? Why? How?
(bytesandlogs.me)
3 points · by
itskarad
· 2y ago · 1 comment
Comments
[–]
Someone
2y ago
The author hacks it in using
const_cast
(
https://en.cppreference.com/w/cpp/language/const_cast
), but doesn’t seem to know
mutable
(
https://en.cppreference.com/w/cpp/language/cv#mutable
) exists for this purpose.