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 3 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.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: