- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why “using namespace std” is considered bad practice in C++
45 Lectures 4.5 hours
66 Lectures 5.5 hours
C++ has a standard library that contains common functionality you use in building your applications like containers, algorithms, etc. If names used by these were out in the open, for example, if they defined a queue class globally, you'd never be able to use the same name again without conflicts. So they created a namespace, std to contain this change.
The using namespace statement just means that in the scope it is present, make all the things under the std namespace available without having to prefix std:: before each of them.
While this practice is okay for example code, pulling in the entire std namespace into the global namespace is not good as it defeats the purpose of namespaces and can lead to name collisions. This situation is called namespace pollution.
- Why the use of "using namespace std' considered bad practice?
- Why is it considered a bad practice to omit curly braces in C/C++?
- Why are women considered bad drivers?
- What does 'using namespace std' mean in C++?
- Why Lord Krishna is considered supreme god?
- Why Dante is considered a great poet?
- Why is river Ganga considered as sacred?
- Why is Tulsi plant considered sacred in Hinduism?
- Why we should avoid using std::endl in C++
- Why is Pablo Picasso considered a great artist?
- Why Anger is considered as self-killer/destroyer?
- Why combination of twitter and facebook is bad
- Why importing star is a bad idea in python