Given this code, is it possible to change dumpStrings()
to be able to iterate over any container of string
, like say a list
I don't think there's anything as simple as you'd like. Ideally, you could just do something like
void dumpStrings(AbstractIterator beg, AbstractIterator end) { }
but the STL iterators don't seem to have any inheritance hierarchy, irritatingly enough. So it looks like you're stuck with using function templates - that's how it's done in the STL Algorithms Library.
Sorry - I wish there was a better way, too, but this'll have to do. Just remember to declare the full function template in the header file!