Sign in to follow this  
agm_ultimatex

quick question about std - efficiency

Recommended Posts

agm_ultimatex    191
I remember reading/hearing somewhere here that the line using namespace std; is best avoided, and its better to use std::cout, std::string, etc. Is this true? and if so, would you be able to explain? Thanks.

Share this post


Link to post
Share on other sites
SiCrane    11839
It has nothing to do with efficiency. You should never use a using directive or declaration in a header since that can change the meaning of subsequent code; however putting using namespace std in a source file after the headers is fine.

Share this post


Link to post
Share on other sites
EdR    117
Quote:
Original post by agm_ultimatex
I remember reading/hearing somewhere here that the line using namespace std; is best avoided, and its better to use std::cout, std::string, etc. Is this true? and if so, would you be able to explain? Thanks.
Using default namespaces makes for somewhat less readable code, in some people's estimation. It's not a question of efficiency, just cleanliness and readability. I don't subscribe to this notion for any language except C++; C++ needs all the help it can get to remain readable and clean.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this