When I was reading some article I saw something stragne (for me) contruction.
When I'm using map I use it like this:
std::map<std::string, MyClass> Map;
//and add elements:
Map['someting'] = myObject;
And this is fine and intelligibly. But in this article I saw this:
MyClass& object = Map['something_new'];
//and then, initialize the object
object.method();
//and later I can use this map
Map['something_new'];
And... it works. But I don't understand how. I initialize this object reference, not map, but this works like I just added an element to my map. Could me explain me this?
Aucun commentaire:
Enregistrer un commentaire