I have a vector of that contains objects that have have inherited the pet class (cat,dog,fish etc). They all have a common override function called play() and I want to call that function with the iterators.
I'm getting bunch of errors. I'm not sure if I am creating my for iterators correctly.
code snippet:
void play_pets_x_Times (const std::vector<Pet*>& t, const int16_t x) {
int i=0;
while (i < x) {
for(std::vector<Pet*>::iterator it = t.begin(); it != t.end(); ++it) {
//error conversion from std::vector<Pet*>....
it->play(); //error request for member 'play' in....
}
i++;
}
}