Is there a difference between the compiler between the two methods (I am using Visual Studio 2005)?
As others have rightly pointed out, no.
What is right?
Between the two alternatives, it boils down to the debate "I have to hide pointers behind typedefs." There are valid arguments for any position.
However, I think that both pieces of code suffer from over-specialization. I prefer to code algorithms as template functions, so I don’t repeat it myself .
If your design supports it, you can generalize your code to accept any iterator:
template <class InputIterator> bool myFunction(InputIterator &iter) { std::cout << *iter; ++iter; return true; }
source share