Counter, Arithmetic Mean and Division by Zero

using Directive and using Declaration

When using standard input, standard output or vectors in our programs so far, we have been obliged to insert a using directive like this:

using namespace std;

The names in libraries are organized by namespaces. The names cin, cout, endl, setw and vector reside inside the std namespace. A using directive imports all those names from the std namespace into the global namespace.

Another way to import names into the global namespace is by utilizing a using declaration, instead of a using directive, like this:

using std::cout;
using std::endl;
using std::vector;

That allows the names cout, endl and vector to be used in the program. A using declaration imports names one by one, while a using directive imports all the names in a namespace at once.

The third possibility is to prefix names from included libraries by an appropriate namespace name. For example:

    std::vector<double> array;
    std::cout << "namespace std contains the name endl, too!" 
              << std::endl;
    std::cout << "It also contains names cin and setw." << std::endl;

The names like std::vector, std::cout and std::endl are said to be fully qualified.