Namespace aliases
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
命名空间别名允许程序员定义的命名空间的另一个名字.....
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.
You can help to correct and verify the translation. Click here for instructions.
它们通常用于长或深度嵌套的命名空间作为一种方便快捷.
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.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 语法
namespace alias_name = ns_name;
|
(1) | ||||||||
namespace alias_name = ::ns_name;
|
(2) | ||||||||
namespace alias_name = nested_name::ns_name;
|
(3) | ||||||||
[编辑] 解释
新的别名alias_name提供的另一种方法访问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.
You can help to correct and verify the translation. Click here for instructions.
alias_name必须是以前没有使用过的名称。 alias_name是有效的持续时间的范围在它被引入.
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.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 为例
#include <iostream> namespace foo { namespace bar { namespace baz { int qux = 42; } } } namespace fbz = foo::bar::baz; int main() { std::cout << fbz::qux << '\n'; }
Output:
42
[编辑] 另请参阅
| 命名空间声明 | 标识命名空间
Original: identifies a namespace The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |