G
gob00st
I found the following paragraphs from C++ pro Danny Kalev's C++
Reference Guide at
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=206
stating:
_______________________________________________________________________________________________________________________________________
Let's look at a concrete example of a map that contains a pair of
strings, the first of which is a name and the second one is an e-mail
address. We create the map like this:
#include <map>
#include <string>
map <string, string> emails;
To add an item to a map, use the subscript operator:
emails["J. Horvath"]="(e-mail address removed)"; //#1
If the map already contains the key "J. Horvath", the current
associated value remains unchanged:
emails ["J. Horvath"]="(e-mail address removed)"; //#2 ,has no effect
_______________________________________________________________________________________________________________________________________
IMHO, this seems wrong. #2 should update the data_value of key "J.
Horvath" to "(e-mail address removed)".
Because I think essentially mymap[k] equals to (*(mymap.insert
(value_type(k, data_type())).first)).second ,which enables #2 to
update the value of key "J. Horvath".
I can not find any contact email of Danny, so I posted this issue
here, I am hoping someone could either confirm I am correct or
opposite.
Any input is appreciated.
Regards,
Gob00st
Reference Guide at
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=206
stating:
_______________________________________________________________________________________________________________________________________
Let's look at a concrete example of a map that contains a pair of
strings, the first of which is a name and the second one is an e-mail
address. We create the map like this:
#include <map>
#include <string>
map <string, string> emails;
To add an item to a map, use the subscript operator:
emails["J. Horvath"]="(e-mail address removed)"; //#1
If the map already contains the key "J. Horvath", the current
associated value remains unchanged:
emails ["J. Horvath"]="(e-mail address removed)"; //#2 ,has no effect
_______________________________________________________________________________________________________________________________________
IMHO, this seems wrong. #2 should update the data_value of key "J.
Horvath" to "(e-mail address removed)".
Because I think essentially mymap[k] equals to (*(mymap.insert
(value_type(k, data_type())).first)).second ,which enables #2 to
update the value of key "J. Horvath".
I can not find any contact email of Danny, so I posted this issue
here, I am hoping someone could either confirm I am correct or
opposite.
Any input is appreciated.
Regards,
Gob00st