0

Possible Duplicate:
Why is 'using namespace std;' considered a bad practice in C++?

I have done a little research and am looking for something close to the definitive answer on whether or not, as a farily new programmer (and very new to C++) I should get in the habit of including "using namespace std;" after my included libraries. OR do you guys recommend I start with identifying the scope everytime and use namespaces later? Namespaces now, namespaces later... The professor leaves it up to us and as our programs are fairly simple right now I don't know if it's too critical either way. I'd love to hear opinions. Thanks!

Community
  • 1
  • 1
MCP
  • 4,436
  • 12
  • 44
  • 53
  • whatever you feel more comfortable with – littleadv Jan 09 '12 at 10:52
  • 2
    http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-a-bad-practice-in-c – kennytm Jan 09 '12 at 10:53
  • The important thing is, don't put `using` *in* your header files (at least, not in the global namespace) - that imposes it on users of the header, possibly breaking their code. Within a source file, it's more a matter of personal taste. – Mike Seymour Jan 09 '12 at 11:45

1 Answers1

2

Get in the habit of not using namespace std. It'll make your life easier when you start using lots of libraries with each their own namespace and potentially conflicting identifiers.

If you want to abbreviate, say, std::cout to cout, you can always declare

using std::cout;
Fred Foo
  • 355,277
  • 75
  • 744
  • 836