Is it necessary to use " using namespace std; "? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is it necessary to use " using namespace std; "?

What does it really do?

25th Aug 2019, 2:31 PM
Sanjaya Acharya
Sanjaya Acharya - avatar
2 Answers
+ 4
If you use "using namespace std;" you can use anything in the `std` namespace without having to type out it's full name: `std::cout` becomes `cout` `std::vector` becomes `vector` It is fine for small programs but discouraged for anything else. The `std` namespace is huge and it dumps all of that into your current namespace. If you use std you can never call a variable `vector` for example because `std` will have already used the name. better is this: void main() { using namespace std; // Using std, but only inside the main function! }
25th Aug 2019, 2:40 PM
Schindlabua
Schindlabua - avatar
0
It's up compiler
25th Aug 2019, 4:17 PM
yogesh lodha
yogesh lodha - avatar