Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I Move a memory pointer in FILE? Pin
Code-o-mat30-Sep-11 3:04
Code-o-mat30-Sep-11 3:04 
AnswerRe: How can I Move a memory pointer in FILE? Pin
Madhu Nair30-Sep-11 3:29
Madhu Nair30-Sep-11 3:29 
AnswerRe: How can I Move a memory pointer in FILE? PinPopular
enhzflep30-Sep-11 3:34
enhzflep30-Sep-11 3:34 
GeneralRe: How can I Move a memory pointer in FILE? Pin
Chris Meech30-Sep-11 7:13
Chris Meech30-Sep-11 7:13 
AnswerRe: How can I Move a memory pointer in FILE? PinPopular
Richard MacCutchan30-Sep-11 10:10
mveRichard MacCutchan30-Sep-11 10:10 
QuestionSetting font size in popup message Pin
nashhashdash30-Sep-11 1:21
nashhashdash30-Sep-11 1:21 
AnswerRe: Setting font size in popup message Pin
Richard MacCutchan30-Sep-11 2:35
mveRichard MacCutchan30-Sep-11 2:35 
Question'Should I use <code>using namespace std;</code> in my code?' Pin
Stefan_Lang30-Sep-11 0:49
Stefan_Lang30-Sep-11 0:49 
I've put the topic in quotes, because I'm not asking for me. Instead I am referring to the various occasions I've seen where people advise inexperienced programmers to add
using namespace std;
to their program. Personally I feel that this is not generally a good advice, for all of the reasons pointed out at http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.5[^].

But maybe the people offering this advice do have their reasons and take a different view? I'd like to know. What is your stance? Why do you think it is good to add a
using namespace
statement, and when?

Or do you agree with me and generally advise against it? If so, can you offer any reasons not already offered at the site I linked above?


P.S.:
After reading the responses I've found there are indeed (IMHO) few strong arguments in favor of using using namespace std;. The two main arguments were:

1. Typing effort
2. Lack of readability, most notably (but not only) with the use of formatting in stream classes

Personally I don't think the typing effort should be considered a valid reason, unless there are absolutely no drawbacks to consider. Apart from that, both cases can be countered by various methods:

1. Use intelligent editors to minimize the typing effort
2. Use typedef to simplify complex (or just hard to type) expressions
3. Use a using declaration (e. g. using std::cout;) rather than a using directive

In those rare cases where, locally, symbols from namespace std are being heavily used (e. g. an output function using lots of formatting), adding a using directive locally (i. e. within the scope of the function only) could be a reasonable compromise. Thanks to Stephen Hewitt for pointing that out.

modified 6-Oct-11 4:55am.

AnswerRe: 'Should I use using namespace std; in my code?' Pin
Erudite_Eric30-Sep-11 0:56
Erudite_Eric30-Sep-11 0:56 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Stefan_Lang2-Oct-11 22:14
Stefan_Lang2-Oct-11 22:14 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Erudite_Eric3-Oct-11 22:00
Erudite_Eric3-Oct-11 22:00 
AnswerRe: 'Should I use using namespace std; in my code?' Pin
Niklas L30-Sep-11 1:13
Niklas L30-Sep-11 1:13 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Stefan_Lang30-Sep-11 1:50
Stefan_Lang30-Sep-11 1:50 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Niklas L30-Sep-11 2:28
Niklas L30-Sep-11 2:28 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Albert Holguin30-Sep-11 8:25
professionalAlbert Holguin30-Sep-11 8:25 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
CPallini30-Sep-11 22:13
mveCPallini30-Sep-11 22:13 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Stefan_Lang2-Oct-11 22:17
Stefan_Lang2-Oct-11 22:17 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
CPallini2-Oct-11 22:35
mveCPallini2-Oct-11 22:35 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Stefan_Lang3-Oct-11 0:42
Stefan_Lang3-Oct-11 0:42 
AnswerRe: 'Should I use using namespace std; in my code?' Pin
Chris Losinger30-Sep-11 7:47
professionalChris Losinger30-Sep-11 7:47 
AnswerRe: 'Should I use using namespace std; in my code?' Pin
Stephen Hewitt30-Sep-11 20:06
Stephen Hewitt30-Sep-11 20:06 
GeneralRe: 'Should I use using namespace std; in my code?' Pin
Stefan_Lang2-Oct-11 22:20
Stefan_Lang2-Oct-11 22:20 
QuestionPrinting Class Library PrintRotatedText Pin
DanYELL29-Sep-11 16:41
DanYELL29-Sep-11 16:41 
AnswerRe: Printing Class Library PrintRotatedText Pin
Roger Allen30-Sep-11 6:23
Roger Allen30-Sep-11 6:23 
GeneralRe: Printing Class Library PrintRotatedText Pin
DanYELL30-Sep-11 6:35
DanYELL30-Sep-11 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.