| | Basic facilities - slide 45 : 46 |
The standard library namespace
All facilities in the C++ Standard Library are defined in the std namespace
- Namespace resolution
- Use the scope operator :: on every name you use from the standard name space
- std::cout << s1 << std::endl;
- Allows for symmetric use of the same names from other namespaces
- Tedious in short and simple programs
- Apply using declarations on selected names from the standard namespace
- using std::cout; using std::endl;
- Tedious, just in another way...
- Apply a single using directive
- using namespace std;
- All names from the standard namespace can be used without qualifiction
- OK for namespace composition - OK in certain local scopes
- Sloppy and lazy if used in the global namespace