The thing is, one shouldn't have
using namespace std;
in their code.
It pollutes the global namespace, and can cause naming conflicts. Did you know there are
std::distance
,
std::left
,
std::right
plus heaps of others that could cause awkward problems.
So if one had a function called distance there would be a problem, as
std::distance
means a very different thing.
One can do this for frequently used things, put them at the top of your file :
1 2 3 4
|
using std::cout;
using std::cin;
using std::endl;
using std::string;
|
Then refer to them without qualification :
1 2 3
|
string MyName = "Fred";
cout << "My Name is " << MyName << endl;
|
Some people use
std::
exclusively.
It is a good idea to put your own code in it's own namepace.
So this is why you see experienced coders put
std::
everywhere
HTH