
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Why āusing namespace stdā is considered bad practice in C++
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.
- Related Articles
- 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 is using onClick() in HTML a bad practice?
- Why crop rotation is considered a good agricultural practice?
- Why are women considered bad drivers?
- What does 'using namespace std' mean in C++?
- Why we should avoid using std::endl in C++
- Why is using the JavaScript eval() function a bad idea?
- Why circular reference is bad in javascript?
- Why is using āforā¦inā loop in JavaScript array iteration a bad idea?
- Why is using āforā¦inā with array iteration a bad idea in javascript?
- Why is Petrol considered a mixture?
- Why is biogas considered excellent fuel?
- Why is Tulsi plant considered sacred in Hinduism?
- Why importing star is a bad idea in python
