O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Namespaces

Almost everything in a program has a name. When you start using libraries, there is always the chance that one library may have something in it that has the same name as something in another library. If that happens, the compiler can't tell which thing you meant to use. So C++ library programmers wrap their libraries in namespaces to keep their names separate.

Namespaces are a sort of container for names. Each namespace itself has a name that qualifies (is added to) any names in the code it holds. For instance, the namespace for iostream is named std (shorthand for “standard”) and any name from that namespace is automatically qualified with std—as in std::cout.

The statement on line 3 tells the compiler, “If you see a name and you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required