Std or using namespace

the difference is not hard but if you are new you might get very confused and make some mistakes so. First I would suggest making your code. Seeing how many times you use overlapping namespaces. If you don’t at all then you are on a simple path to a fix. Now you might want to use the documentation to verify if your libraries share the same namespace. If not you can declare 'using namespace ; If not you might want to use it on each entry… but I can save you some effort. IF you use it many times and IF it is used by one of your other includes then you can declare it … using std ::; This would ensure you use the std version each time you type in _______ .

That’s a lot of headache and effort. Also who knows what library/header you might use in the future or maybe have a library get updated that will break your code simply because you used ‘using namespace x’. I would just not bother with it.

Yep. In some applications you won’t ever run into a problem but many times, especially if your code is evolving, you will. It’s only a few more typed characters and it’s exact. NO guesswork involved. But in response to the assignment I offered up alternatives. I could have taken the easy way out and just said it can be a problem if you do" " and explain just that.

Privacy & Terms