Right,
I have a Package class with a public method double calculate_cost ().
I need to create a std::map<string, std::vector<Package*>>
in which I can iterate through the vector and save the return of the calculate_cost () method on a variable. Home
(The map is std::map<std::string, std::<vector<Package*>> packagemap;
)
I've been tempted in some ways, including:
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 get this error in most attempts:
error: invalid conversion from 'Package *' to 'std :: vector :: size_type' {aka 'long unsigned int'} [-fpermissive] total + = mit- > second [* vit] .calculate_cost () ;
^~~~
This blend of map and vector pointers has got me pretty confused. Thanks for your help!