0
Using namespace std?
I am not understanding this. For what it is exactly used?
3 Answers
+ 1
I think it allows you to access objects within the standard library. A standard library is like a dictionary, and by 'using' it, you are allowed to write code with 'definitions' from that dictionary (library). It's like trying to make a cat, but if you don't have a definition for what a cat is, you can't really make a cat. Not a 'standard' one anyway. Hope that helped :)
+ 1
It allows you to call std functions without giving a fully-qualified name for the function.
Ex:
(Without the using statement, this is what you would need to write to access std's cout function)
std::cout<<"I am a fully qualified name\n";
(With "using namespace std")
cout<<"I am not a fully-qualified name.\n";
The above code is only allowed because you tell the compiler to essentially auto use the namespace for any std functions you use. You can use your own namespaces as well. They are mostly used to prevent name clashes between other libraries and blocks of code.
0
Thank you