Using the namespace twice

In C ++ Is it possible to include the same namespace twice? the compiler will not give any error, but it will still affect anyway

Thanks,

EDIT:
I meant

using namespace std;

// . . STUFF
using namespace std;
+3
source share
5 answers

It depends on what you mean by include. Saying:

using namespace std;    
...    
using namespace std:

in order. But saying:

namespace X {
   ...
namespace X {

will create a nested X :: X namespace, which is probably not what you wanted.

+15
source

This use is great if that is what you are talking about:

File: foo.h

namespace tools
{
  class Widget
  {
  ...
  };
}

file: bar.h

namespace tools
{
  class Gizmo
  {
  ...
  };
}
+8
source

/? , . , , .

+3

, . ( ). , , .

, , , .

use: / intellisense (# 1), .

+1

, ?

using namespace std;
using namespace std;

, .

:

std::vector
std::sort
+1

Source: https://habr.com/ru/post/1710569/


All Articles