for (petIter it = pets.begin(); it != pets.end(); ++it)
(*it)->eat();
(*it)->function(); just seems so not elegant, but this type of aggregation/inheritance is so common in C++ and is what C++ was really designed for. There has to be a better way.
Stuck in VS2008 for work. No C++11 there. I do like the range-based for loops, but I'll look-up smart pointers. Maybe it would be worth re-implementing in our utility library.
The only C++03 solutions I can think of make it more complex/annoying for the surrounding code. AFAIK I haven't seen anything better than what you have, and it's not too terribly annoying. Sometimes I have fun:
1 2
for (petIter it = pets.begin(); it != pets.end(); ++it)
it->operator->()->eat();