Search⌘ K
AI Features

Using Namespaces

Explore how to manage namespaces in C++ to correctly apply using declarations and directives, avoid naming conflicts, and use namespace aliases for clarity. Understand best practices to safely include standard libraries and prepare your code for building executables.

If you use qualified names, you have to use them exactly as defined. For each namespace you must put the scope resolution operator ::. More libraries of the C++ standard library use nested namespaces.

C++
#include <iostream>
#include <chrono>
...
std::cout << "Hello world:" << std::endl;
auto timeNow= std::chrono::system_clock::now();

Unqualified Use of Names

You can use names in C++ with the using declaration and the using directive.

Using Declaration

A using declaration adds a name to the visibility scope, in which you applied the using ...