This question has already been answered:

I'm just starting to delve into C ++. In different sources (yes, even different comrades), sometimes opposite things are advised, namely:

  • it is better to always connect the namespace completely ( using namespace std; ),
  • it is better to always include only those names that are actually used ( using std::string; ).

How correct?

Reported as a duplicate by members Abyx , PashaPash , Vladyslav Matviienko , Visman , fori1ton Aug 31 '15 at 6:07 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

4 answers 4

Depends on the specific situation. If you just start learning, don't bother with it. For now, always include std completely. Focus on more important things.

    It does not matter much, just empty perfectionism, it is better to focus on really significant issues. In fact - if you use a lot of any classes from neymspeysa, then declare each separately, obviously, hemorrhoids, and does not give any special advantages.

      I use using namespace inside functions when full qualifications can make the code more readable.

       void а() { using namespace std; for_each(...) } 

        I personally prefer either to use using namespace std; either explicitly in the code to write std::string or std::cout (as I usually do), but I certainly won't use using std::string; .

        If the project is large enough, then clearly register each type - it will be horror. And if there is still a couple of libraries with the same name, then there will be complete horror. For each type you will need to remember which library it belongs to.