Using namespace std? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Using namespace std?

I am not understanding this. For what it is exactly used?

10th Aug 2016, 6:46 PM
Pathikrit Saha
Pathikrit Saha - avatar
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 :)
10th Aug 2016, 7:53 PM
Amir Mansaray
Amir Mansaray - avatar
+ 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.
10th Aug 2016, 8:13 PM
Donovan
Donovan - avatar
0
Thank you
10th Aug 2016, 8:06 PM
Pathikrit Saha
Pathikrit Saha - avatar