One reason why using a namespace can be bad is that when another programmer is looking at your code they might not know what namespace the object comes from if you’re using multiple namespaces. It can also cause an issue if the object is referenced in more than one namespace.
I saw a suggestion which might help limit the damage of a namespace collision:
similar to how in Python you would:
from math import sin
in C++ you can do this:
and it doesn’t include the entire std library.
Hey, thanks for letting me know this!
using Namespace can be bad because:
- Can create conflicts with other libraries that contains the same string for other reasons.
- Can promote poor programming due to the need for short cuts.
For my code exercise, I used the following: