Lecture 3 - Slide 24 : 27
Namespace resolution
All facilities in the C++ Standard Library are defined in the
std
namespace
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 name from another namespace
Tedious in 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 qualification - not a good solution at all
OK for namespace composition - OK in certain local scopes
Sloppy and lazy
if used in the global namespace
The C++ Prog. Lang. (3. edition)
:
Page 179: Namespace composition