vector> zoo; zoo.emplace_back(new Elephant); zoo.emplace_back(new Zebra); zoo.emplace_back(new Bear); cout << "Feading time (f) or Bedtime (b)?"; char c; cin >> c; void (Animal::*ap) () = c == 'f' ? &Animal::eat : &Animal::sleep; for (auto it = zoo.begin(); it != zoo.end(); it++) { ((**it).*ap)(); // can't use '->' with unique ptrs }