◐ Shell
clean mode source ↗

Namespace aliases – cppreference.com

Aus cppreference.com

<metanoindex/>

Namespace Aliase ermöglichen es dem Programmierer, um einen alternativen Namen für eine Namespace definieren .

Original:

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

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sie werden üblicherweise als eine bequeme Abkürzung für lange oder tief verschachtelten Namespaces verwendet .

Original:

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

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Syntax

namespace alias_name = ns_name; (1)
namespace alias_name = ::ns_name; (2)
namespace alias_name = nested_name::ns_name; (3)

Erklärung

Die neuen Alias ​​alias_name bietet eine alternative Methode für den Zugriff ns_name .

Original:

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

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

alias_name muss ein Name bisher nicht verwendet werden. alias_name ist für die Dauer der Rahmen in den sie eingeführt gültige .

Original:

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

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Beispiel

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

Output:

Siehe auch