"using namespace" pros and cons

Using “using namespace” can have it’s pros and cons.

Pros:
It allows you to use namespaces throughout the code without needing to write the namespace at each instance. For example, instead of writing “src::cout << “Text here” << src::endl”, put “using namespace src;” at the top of the file and use “cout << “Text here” << endl”.

Cons:
It makes it harder to determine which namespace or library the command is being used from.

Privacy & Terms