0
All right,
I have a Package class with a public method double calculate_cost().
I need to create a std::map<string, std::vector<Package*>>
where I can iterate through the array and save the return of the calculate_cost() method into a variable.
(The map is std::map<std::string, std::<vector<Package*>> packagemap;
)
I’ve been tempted in some ways, among them:
std::map<std::string, std::vector<Package*>>::iterator mit;
std::vector<Package*>::iterator vit;
double total{0};
for (mit = packagemap.begin(); mit != packagemap.end(); ++mit) {
for (vit = mit->second.begin(); vit != mit->second.end(); ++vit)
total += mit->second[*vit].calculate_cost();
But I’ve been getting this mistake most of the time:
error: invalid Conversion from ːPackage*' to ːStd::vector::size_type' {aka 'long unsigned int'} [-fpermissive] total += mit->Second[*Vit]. calculate_cost();
^~~~
This mix of map and pointer vector has confused me a lot. I appreciate help!