I have two vector structs, one contains the codes and cost for each, and another is just orders that contains requested codes and totalCost (to be calculated)
vector<Parts> parts(codes, cost);
vector<Orders> orders(codes, totalCost);
where the parts vector contains something like ('A', 10, 'B', 20);
Where A and B are parts, 10 is cost for A, 20 cost for B.
and the orders vector contains orders such as A,B,C or just A,B Say we receive an order of parts A and B.
how do we go about adding these two based on cost from parts and storing the result in a new int that we gonna use later to add to the vector struct orders (totalCost).
I was trying for several hours, I think I need to use std::transform and maybe std::accumulate? just not sure how to put the two together...
Any help is greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire