---
# System prepended metadata

title: 'TotW 12: `using namespace` in global scope of headers is BAD'
tags: [C++]

---

# TotW 12: `using namespace` in global scope of headers is BAD
Part of the [Tips of the Week](Tips-of-the-Week) series
###### tags: `C++`

### Examples of good and bad usages of `using namespace` 

```cpp
// MyHeaderFile.H

using namespace rdx; // BAD!

namespace my_namespace {
    using namespace rdx; // This is better
    // beware though, your namespace will include all the rdx declarations!
}

void my_cool_function() {
    using namespace rdx; // perfectly fine!
}
```

### What is wrong with that?

By using a namespace, you're polluting the current scope with all the declarations of that namespace. While this might be okay inside a scope, or inside another namespace (or in a `.C` file that is not included by anyone), in this way the same name pollution will affect anyone which includes.