Alex Rivera | Logout

Is using namespace..like bad?

Asked 2010-10-28T14:37:05.490
23

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

Every time I use using namespace std I always get that "thats a terrible programming habit". Now I'm graduating this December with my B.S. in C.S. but I don't claim to know everything, but no one has ever explained why this is so bad. I understand what it does but I honestly don't see a huge deal with it.

Anyone care to explain? In my mind it just makes typing cout a whole lot more bearable than std::cout.

I can understand why you wouldn't want to put it in a header file, but just in a normal implementation file... I dont see why it would be a problem.

Edit
Report

1 Answer

2

It's primarily about good housekeeping. If you're not really going to use more than a few identifiers in a namespace, why clutter up your own namespace by dumping all of the identifiers from that namespace into yours? It's preferable to use using std::cout. However, if you use a namespace very heavily and it doesn't cause any collisions, go ahead and use using namespace.

answered 2010-10-28T14:42:48.577

Your Answer