Click to See Complete Forum and Search --> : Whats Wrong With "using namespave std;"?


Arcane_Disciple
02-23-2003, 10:49 PM
Just wondering about this. Some of my profs frown on it while others require it. Is there a reason that this tiny little time saver is frowned upon?

bwkaz
02-23-2003, 11:35 PM
Yep, it makes putting all the standard classes and objects into the std namespace completely pointless.

"using" statements import symbols from another namespace. The <iostream> header (and all the other C++ standard library's headers) put all their symbols into a namespace called std, so that programmers can redefine some of the class or object names without causing too much confusion. When you pull in the entire std namespace with a using namespace std;, you defeat the entire purpose of this separation.

It's a lot cleaner to only import the symbols you use. Sure, it takes 5 lines of code rather than one, but when you're talking that little, who really cares? Your program is a thousand times longer than that anyway.