using namespace std;
Hello,
I wanted to find out how many C/C++ developers actually use this in their programming. |
It has limited usefulness for learning C++, but it ultimately promotes vague code and dumps common names into the global namespace, possibly introducing bugs. I think in non-trivial programs it's a lazy shortcut that provides minimal additional convenience at best. You can place using... between headers to keep headers after it from dumping into the global, but that makes it more confusing.
There is one exception, though. Some STL libraries (though not necessarily compliant) place standard C functions in namespace std. Putting using... in the local scope of a function can be useful to promote portability to those compilers and it has no effect outside of that scope. ta0kira |
I do not put “using namespace std;” in my code. If I need to dump anything from a different namespace into mine (if I use it many times), I will explicitly import only those and nothing else. E.g.,
Code:
using std::vector; |
All times are GMT -5. The time now is 06:01 PM. |