It is typical to put the line:
using namespace std;
at the top of a file which makes use of std library objects. To take
a simple example:
#include <iostream>
using namespace std;
int main( ) {
int not_std_namespace = 1;
cout << "Hello World" << endl;
cout << not_std_namespace << endl;
return (0);
}
How does C++ know that the variable not_std_namespace is not in the
std:: namespace? Or is it automatically put there? That is, because
of the "using namespace" directive at the top of the file, references
to "cout" are treated as "std::cout." So why isn't
"not_std_namespace" treated as "std::not_std_namespace"? Or does C++
first search the local namespace, and then search the std:: namespace?
Thanks for any clarification,
cpp