Hacker News new | past | comments | ask | show | jobs | submit login
Can you change state in a const function in C++? Why? How? (bytesandlogs.me)
3 points by itskarad 9 months ago | hide | past | favorite | 1 comment



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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: