LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

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

Rep: Reputation: 30
using namespace std;


Hello,

I wanted to find out how many C/C++ developers actually use this in their programming.
 
Old 03-06-2008, 01:25 PM   #2
ta0kira
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.
ta0kira
 
Old 03-06-2008, 01:41 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
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;
using std::fstream;
 
  


Reply


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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:51 AM.

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