I am needing to pass an entire vector of objects to a constructor of another class. I have succeeded in doing this with a single vector object, but with the entire vector, it's giving me trouble.
Here is the code.
classes.h:
class Star: public Spell
{
public:
Star(std::vector<Hero>& hero_list): h_list(hero_list) {}
protected:
std::vector<Hero>& h_list;
}
spells.cpp:
Star::Star(std::vector<Hero>& hero_list): h_list(hero_list)
{
}
and then the call from main.cpp:
std::vector<Spell*> spells;
spells.push_back(new Star(*heroes));
Right now, it's not liking the call. I get: "Error: no operator "*" matches these operands"
I have similar code that is working just fine with passing a single object from the vector, but not this.
I need to pass the entire vector for this particular spell sub-class so it can check values of multiple hero objects and make changes to them.