Afficher un message
Vieux 07/02/2008, 15h56   #1
subramanian100in@yahoo.com, India
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut need for operator[] in map

For inserting new elements in map, we can use insert member function.

To know if an element exists or not in a map, we can use count or find
member function.

Also, we can use the iterator returned by find to modify the mapped
value of an existing key.

When we use operator[], it may add an element into the map if the key
already doesn't exist, which may not be always wanted.

Given this, I am unable to understand the reason as to why we have
operator[] in map whose functionality can be achieved by other member
functions.

Kindly clarify.

Thanks
V.Subramanian
  Réponse avec citation
 
Page generated in 0,06230 seconds with 9 queries