Namespace without a name in C++

C++Namespaces

C++ Problem Overview


> Possible Duplicate:
> Unnamed/anonymous namespaces vs. static functions

I came across this code

namespace ABC {
namespace DEF {

namespace
{

I expected the namespace should be followed by some name, but it's not the case with this code.

Is this allowed in C++? What's the advantage for this unnamed namespace?

C++ Solutions


Solution 1 - C++

It's called an unnamed namespace / anonymous namespace. It's use is to make functions/objects/etc accessible only within that file. It's almost the same as static in C.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionprosseekView Question on Stackoverflow
Solution 1 - C++MarlonView Answer on Stackoverflow