I have a map in my program that stores the code of a Product p and the amount of it.
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.
How can I do this?
void Request :: addItem (Product p, double amount) {
if(this->isItemRequest(p)) {
//p already exists in the map.
}
this->rdata.insert(pair<int, double>((int)p.getCode(), amount));
}
Thanks a lot!