Lecture overview -- Keyboard shortcut: 'u'  Previous page: More manipulators -- Keyboard shortcut: 'p'  Next page: More namespaces -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 37 : 42
Notes about C++
Basic facilities
Logical program organization

Namespaces are used for the logical program organization of C++ programs

  • The C++ Programming Language: Page 167, 847
 

  • Namespaces

    • A namespace is a named scope

    • Usages of names require namespace qualification

      • namespace::name_within_namespace

    • A using declaration can be used to add a name (an alias) to a local scope (such as a function)

      • using N::name;

      • name is declared/defined as a local synonym to N::name

    • A using directive allows convenient access to names from a given namespace

      • using namespace N;

      • Can - and should - be used locally, in a function for instance

Names declared in a namespace - natively or by using declarations - take priority over names brought in via using directives

 

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/namespaces/namespace-1.ccIllustration of using declarations and using directives.