title: Adding elements into a c++ map
body: <p>I have a map in my program that stores the code of a Product p and the amount of it.</p>
  
  <p>If a ask for a new request, and if the product already exists in the map, i just need to sum the second element of the pair(code, amount) to the element in the map.</p>
  
  <p>How can I do this? </p>
  
  <pre><code>void Request :: addItem (Product p, double amount) {
      if(this-&gt;isItemRequest(p)) {
          //p already exists in the map.
      }
  
      this-&gt;rdata.insert(pair&lt;int, double&gt;((int)p.getCode(), amount));
  }
  </code></pre>
  
  <p>Thanks a lot!</p>