+ 5

Why do you recommend "using namespace std"?

I've seen it coud be problematic and dangerous to use namespaces like this in real coding, why does it show in your c++ tut.?

27th May 2019, 11:11 PM
Z Ur
4 Answers
+ 7
I wouldn't recommend it. Especially not in header files (due to namespace pollution). I believe similarly - the C tutorial shows you how to get a string using gets() which is a deprecated function with potential for buffer overruns and should never be used. They should probably change those courses or add a warning of some kind.
27th May 2019, 11:41 PM
Cluck'n'Coder
Cluck'n'Coder - avatar
+ 10
You probably would not like using std::cout everything you want to output something, just cout would be better wouldn't it? Same for cin as well.
27th May 2019, 11:36 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
I think similar questions have been asked in the past. Did you try to search for them?
28th May 2019, 1:37 AM
Sonic
Sonic - avatar
0
Using one namespace wouldn't hurt but if you're programming with a lot of namespaces then you may encounter some errors. These are dangerous especially if you're making a project cuz then one error could lead you to search through your entire code. "using namespace std;" wouldn't cause any problems but I would definitely not recommend using more more namespaces other than that.
5th Jun 2019, 4:10 PM
Arashk
Arashk - avatar