+ 3
Is it bad to write "using namespace std" and if so why?
I have heard that it is not a good practice to write "using namespace std" at the beginning of your program and that it is better to write directly: std::cout or std::cin Why is this?
5 Answers
+ 5
Take a look at Ace's thread and his own response in it. It should give you a good idea on why the practice isn't too healthy, especially for beginners who don't know what they are doing.
https://www.sololearn.com/Discuss/294730/?ref=app
+ 1
The main reason people say to not include using namespace std is in case of updates. Say namespace foo got an update with cout in it, the program would get confused over if you meant foo::cout or std::cout, creating errors. It is also just good practice incase if you want to learn something like HTML where you cannot say using <p>
+ 1
Thank you!
0
Why then does the sololearn course for c++ use it? Shouldn't it be logical for beginners not to get into bad habits?
0
Marie if coding is your first language, like me, it is difficult enough to remember what to code in general, of course after a while when people like me and you do research on this topic usually we start using std:: . So as putting std before everything is better, it just makes it easier to memorize what to code, even if in the future you get an error.