Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
No literals most likely will exist in static memory area of application that cannot be modified. (try experiment: open your executable with hex editor and find your literal:) easier with string literals) constants on the other hand is a tool for you and compiler to better optimize your code. you can still modify (try to avoid it) constants with help of 'mutable' keyword, you can go even further by modifying memory andress that const object points to, but you need to inform compiler about this using std::launder
20th May 2017, 8:05 PM
Mindaugas Vinkelis
Mindaugas Vinkelis - avatar