1. Combined use with map
We know that the element type of map is pair, and the elements <key, value> appear in pairs. The key value is a const type, and the value is mutable, we try to change the value value
As shown in the figure, we found a problem. The value of value should be changed from "haha" to "haha1", but it is not absent here. This is inconsistent with our logic, so I use a standard for statement to verify:
It turns out that there is no problem with the standard for. What is the problem with auto, so I did another experiment:
After adding the reference, the problem is solved, indicating that auto does not share the same storage space when associating the variable ma, but a copy.