A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../keyword/../language/namespace_alias.html below:

Namespace aliases - cppreference.com

Namespace aliases allow the programmer to define an alternate name for a namespace.

They are commonly used as a convenient shortcut for long or deeply-nested namespaces.

[edit] Syntax namespace alias_name = ns_name; (1) namespace alias_name = ::ns_name; (2) namespace alias_name = nested_name::ns_name; (3) [edit] Explanation

The new alias alias_name provides an alternate method of accessing ns_name.

alias_name must be a name not previously used. alias_name is valid for the duration of the scope in which it is introduced.

[edit] Keywords

namespace

[edit] Example
#include <iostream>
 
namespace foo
{
    namespace bar
    {
         namespace baz
         {
             int qux = 42;
         }
    }
}
 
namespace fbz = foo::bar::baz;
 
int main()
{
    std::cout << fbz::qux << '\n';
}

Output:

[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4