# "using namespace" in header files is bad practice

**URL:** <https://forum.codewithmosh.com/t/using-namespace-in-header-files-is-bad-practice/27250>\
**Category:** C++\
**Created:** [June 20, 2024, 1:27pm UTC](https://forum.codewithmosh.com/t/using-namespace-in-header-files-is-bad-practice/27250 "2024-06-20T13:27:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brokkolibri](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@brokkolibri](https://forum.codewithmosh.com/u/brokkolibri)\
**Post date:** [June 20, 2024, 1:27pm UTC](https://forum.codewithmosh.com/t/using-namespace-in-header-files-is-bad-practice/27250/1 "2024-06-20T13:27:06Z")

</div>

I’m really baffled that this used and thus shown as (presumably) good practice in so many of the C++ course videos. For instance in Ultimate C++ Part 3: Advanced - 5- Overloading the stream insertion operator:

 ![using namespace std](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/8/830ca6def3aca35e48ca3b55f944d76b61073f0a.jpeg)

This is bad practice and should be avoided.

Also see for instance: ["using namespace" in c++ headers - Stack Overflow](https://stackoverflow.com/questions/5849457/using-namespace-in-c-headers)

---

<div class="post-metadata">

**Author:** ![Haydar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/haydar/32/8542_2.png) [@Haydar](https://forum.codewithmosh.com/u/Haydar)\
**Post date:** [August 13, 2024, 1:55pm UTC](https://forum.codewithmosh.com/t/using-namespace-in-header-files-is-bad-practice/27250/2 "2024-08-13T13:55:15Z")

</div>

You are absolutely right @brokkolibri .  
This is a bad practice that should be avoided.

Having said that, you have to look at this from a complete beginner’s point of view.  
I believe Mosh was only trying to keep distractions away from new learners and to simplify the code as much as possible, so it is easy to contemplate.
