Why using namespace instead of std:: can be a risk

using namespace can be a risk while coding, because you can come out with 2 problems. The first one comes when your library has 2 or more methods with the same name, wich can result in a namespace clash, like a collision of both or more methods with the same name that actually have different purpse. The second problem has the same result of risk of collision, but the cause is different, its when you use Using namespace multiple times inside the library, because it will search for the method like “in the same place” wich means that if you already used ‘cout’ in your first “using namespace”, now it will search for the same “cout”, having a second, third, or so on new “using namespace” doesnt mean anything more than its just going to search again for all the couts it can find in the library.

Sorry for my grammar, still learning how to write better in english :stuck_out_tongue_closed_eyes:

Privacy & Terms