Updation issue in maps stl

is it true that if we write ,let say,map[“banana”]+=120;
and key banana is not present then every time the initial value of key banana will be taken as zero and 120 will be added to it?

Hi @Rj.25

Not every time, but it will get updated to 120 the first time it comes across this statement. Then value of it becomes 120 for next statement and so on.

Hope it Helps.

actually i am asking that its always that for the first time it gets updated to 120 or i120 can be added to some garbage value when the key value pair for banana is created?

Whenever new key value is created, value of it is initialized to 0.