It violates encapsulation rules. Functions defined in different namespaces can only be called by their scope operator (i.e. std::shuffle). Using namespace std assumes that the default is std:: for all functions. This can lead to ambiguity in some cases and in others you will be calling a function you do no intend to. A brief example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <algorithm>
usingnamespace std;
void shuffle(std::vector<int>& numbers)
{
//create custom function for sorting a vector of integers
}
int main()
{
vector<int> test = {1,2,3,4,5};
//which shuffle is being called?
//Local shuffle or std::shuffle?
shuffle(test);
return 0;
}
It is always better to use specific scope than to assume use of a namespace.