My explanation for why "using namespace std;" could produce problems!

When coding, putting:

using namespace std;

outside of a function might seem useful because you no longer have to write:

std:: 

all the time, but if you later want to use methods from namespace x:

using namespace x;

and this namespace has an overlap of method names with std, then it won’t be clear which namespace the methods should come from and the methods with the same names might do different things!

Privacy & Terms