Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


View Poll Results: Do you program with - using namespace std; -?
Yes 4 57.14%
No 3 42.86%
Maybe 0 0%
Voters: 7. You may not vote on this poll

  Search this Thread
Old 03-06-2008, 12:47 PM   #1
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Rep: Reputation: 30
using namespace std;


I wanted to find out how many C/C++ developers actually use this in their programming.
Old 03-06-2008, 01:25 PM   #2
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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.
Old 03-06-2008, 01:41 PM   #3
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 77
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.,
using std::vector;
using std::fstream;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ipc namespace ,what is it and how it was used extremeware Linux - General 0 10-02-2007 02:51 AM
how to get an inventory of what's in namespace std?? santana Programming 2 03-19-2007 05:02 PM
namespace vs classes in C++ xeon123 Programming 3 02-18-2007 03:08 AM
What is "using namespace std"? NCC-1701&NCC-1701-D Programming 1 06-29-2005 08:56 AM
`cout' undeclared in namespace `std' aw_wolfe Programming 1 04-30-2005 09:25 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration