Rediscovering std Namespaces - C++

The standard namespace is a namespace that encapsulates the entire C++ standard library, including the iostream library and the string library that you have been using so far. The using namespace std brings the standard namespace into the global namespace.

This is a very useful line because it enables you to use the code without concern about it being of a different scope than the global namespace. Here, as an example, is a relatively simple program:

If you try to create the equivalent program without using the standard namespace in the global namespace, you have to use the scope resolution operator. In this example, you must use the scope resolution operator eight times to keep the same functionality.

The moral of this story is to use standard namespaces; they make your life much easier.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

C++ Topics