There is a risk when you add this line of code to a C++ program:
using namespace std;
It means you are exposing the entire std namespace. That does make things cleaner and easier most of the time, since you don't have to write std:: all the time. Let's face it, this is ugly:
std::cout<< prev(g) <
But the risk when you do that is name collision. You happened to choose a function name, prev, that also exists in the std namespace (see link). And the signature of your prev function just happens to be close enough to the signature for std::prev that the compiler wants to use std::prev. But it can't quite get there, and issues the typical impossible for most humans to read or understand C++ error message.
3 ways to fix it:
1) Get rid of using namespace std, then prefix things like cout with std::
2) Change the name of your prev function to something else (that isn't already used in std).
2) Use :: to reference g in the global namespace:
cout << ::prev(g) <
(There are other ways to fix it as well, but those are the simplest I can think of).
ETA: @husoski. Enjoyed reading your answer. I haven't written C++ code for a living for close to a decade, but I still try to keep up with the language. I'm curious about 1 point: Once you bring in the std namespace, aren't you really saying you accept the entire scope of the namespace? Or are you supposed to be guaranteed that you only get the subset of the namespace that comes directly from the files you include? Microsoft is obviously #including other things on your behalf here, which introduces more of the std namespace, including prev. But is that really a bug? If g++ just happens to bring in a smaller subset of the namespace, is that really a Microsoft bug? (I'm really not trying to be argumentative here. I honestly don't know what the rules are. But I'm thinking that once you start using namespace std, the compiler is free to give you the entire namespace? Regardless of what you #include? Does the spec address this?)