freeze method, which makes an object dynamically becomes a constant. Is there a way to achieve this in C++? like first give value to a std::string, then lock it to prevent further modifications.
freeze method, which makes an object dynamically becomes a constant. Is there a way
Share
You declare the object as const.
By using the
constqualifier you can initialize the object while creating it & any attempts to modify that object during the course of the program will lead to Undefined Behavior, which basically means users are forbidden from modifying it, this will simulate the freeze effect you are looking for.