using namespace std, std::x

ok, I'm new to c++, and I've been reading Accelerated C++, and in all of there code examples the use std::cout << "hello, world" << std::endl;
insted of using using namespace std;
so my question is why? why dosn't he use using namespace std; insted ? is there a reson ?

thanks in advance :)
Indiscriminate importing of namespaces can lead to ambiguities.
For example, if you import the entire boost and std namespaces, trying to use shared_ptr would result in a compiler error, as it wouldn't know whether you meant boost::shared_ptr or std::shared_ptr (or maybe even std::tr1::shared_ptr).
So you can either always fully qualify your names (bad idea) or import frequently used names selectively (better idea), for example using std::cout.
You can introduce subtle hard to find bugs with using namespace std so its not recommended for serious programming. You can get away with it for trivial examples but it is best to avoid it.

http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.5
@Galik thanks that link really cleard things up :)
Topic archived. No new replies allowed.