This is my code for merging the description and price from two different files and store it in 'priceList'. My problem is, whenever I make an object of 'product', it gives me error of no viable conversion from 'w9::Product *' to 'w9::List<w9::Product>.
I tried to do std::unique_ptr<w9::Product> product (new w9::Product(desc[i].desc, price[j].price));
but it won't me add the product to priceList as it says no viable overloaded +=
w9::List<w9::Product> merge(const w9::List<w9::Description>& desc,
const w9::List<w9::Price>& price) {
w9::List<w9::Product> priceList;
for(int i = 0; i < desc.size(); i++) {
for(int j = 0; j < price.size(); j++) {
if(price[j].code == desc[i].code) {
w9::List<w9::Product> product = new w9::Product(desc[i].desc,
price[j].price);
priceList += product;
}
}
}
return priceList;
}
The output should be like this :
Code Description
4662 tomatoes
4039 cucumbers
4056 brocolli
4067 lemons
4068 oranges
Code Price
4067 0.99
4068 0.67
4039 1.99
4056 2.49
Description Price
cucumbers 1.99
brocolli 2.49
lemons 0.99
oranges 0.67
Also, List is a class template so I assumed that typename T is std::unique_ptr and I am not allowed to change the codes from my header files which inludes the List and Product, Description and Price.
Aucun commentaire:
Enregistrer un commentaire