LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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


Reply
  Search this Thread
Old 02-20-2009, 12:41 PM   #16
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62

Quote:
Originally Posted by Jeebizz View Post
I thought that (at least according to C++ From the Ground Up (book)), that using namespace std; is a way to guarantee that there won't be any namespace conflicts, and as I said before not only std::cout<< seems weird, but also too long winded.
By using "using namespace std" you are putting EVERY symbol in std namespace (which is huge) into global namespace. It a good way to generate namespace conflicts or ambiguities, not to prevent it, so it should be used very wisely. It will be smarter to use just one symbol you need instead of exposing contents of entire namespace.

Quote:
Originally Posted by Jeebizz View Post
What does stripping do anyways?
Removes all debug information. unstripped binary can be 5..10 times larger than stripped one.

Quote:
Originally Posted by Sergei Steshenko View Post
At the moment you import something, you get a risk of name conflict.

If you always use std::cout, std::cerr, std::cin, you don't.
It's not quite right. "never importing anything from namespace" doesn't make much sense.

It is possible to import only std::cin ("using std::cin;") instead of entire namespace.
Code:
#include <iostream>
using std::cout;
using std::endl;

int main(int argc, char** argv){
    cout << "1234" << endl;
    return 0;
}
And it is possible to import namespace (or symbol from namespace) only within one function or block which will be wiser move.
Code:
#include <iostream>

int main(int argc, char** argv){
    using namespace std;
    cout << "1234" << endl;
    return 0;
}
Code:
#include <iostream>

int main(int argc, char** argv){
    {
         using namespace std;
         cout << "1234" << endl;//works
    }
    cout << "1234" << endl;//compiler error
    return 0;
}

Last edited by ErV; 02-20-2009 at 12:42 PM.
 
  


Reply



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
[SOLVED] Quirky Trash Error DragonSlayer48DX Ubuntu 1 02-10-2009 06:10 AM
quirky OS or irresponsible sys admin? edsmithers Linux - Newbie 1 11-24-2003 03:47 PM
Quirky Mozilla Behavior Comatose51 Linux - Software 2 05-01-2003 03:20 PM
quirky comments upon logging in N_A_J_M Linux - General 2 04-17-2003 06:52 AM
X Crash *quirky this one is* DaFrEQ Linux - General 5 10-31-2002 02:14 PM

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

All times are GMT -5. The time now is 10:30 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