Namespaces
提供: cppreference.com
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
名前空間は、大規模なプロジェクトで、名前の衝突を防止するための方法を提供する.
Original:
Namespaces provide a method for preventing name conflicts in large projects.
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:
Symbols declared inside a namespace block are placed in a named scope that prevents them from being mistaken for identically-named symbols in other scopes.
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:
Multiple declarations of namespaces with the same name are allowed, resulting in a namespace including all symbols from all such declarations.
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 ns_name { declarations } | (1) | ||||||||
inline namespace ns_name { declarations } | (2) | (C++11およびそれ以降) | |||||||
ns_name:: name | (3) | ||||||||
using namespace ns_name; | (4) | ||||||||
using ns_name:: name; | (5) | ||||||||
[編集]説明
This section is incomplete |
名前空間name第宣言.
Original:
# Declaration of the namespace 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.
名前空間name第宣言。定義は、内部nameとその外側の名前空間の両方が表示されます
Original:
# Declaration of the namespace name. Definitions will appear both inside name and its enclosing 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:
# Standard way of accessing namespace content.
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.
#usingディレクティブのスコープ内でアクセス可能な名前空間のすべてのシンボルを作る.
Original:
# Making all symbols of a namespace accessible in the scope of the using directive.
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.
#usingディレクティブのスコープ内でアクセス可能な名前空間の特定のシンボルを作る.
Original:
# Making a specific symbols of a namespace accessible in the scope of the using directive.
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.
[編集]例
この例では、すでに
std
名前空間で指定されたクラスを作成するために名前空間を使用する方法を示しています。. Original:
This example shows how to use a namespace to create a class that already has been named in the
std
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.
#include <vector> namespace vec { template<typename T >class vector {// ...}; }// of vec int main(){std::vector<int> v1;// Standard vector. vec::vector<int> v2;// User defined vector. v1 = v2;// Error: v1 and v2 are different object's type. {usingnamespace std; vector<int> v3;// Same as std::vector v1 = v3;// OK} {using vec::vector; vector<int> v4;// Same as vec::vector v2 = v4;// OK} return0;}
[編集]参照
名前空間のエイリアス | 既存の名前空間のエイリアスを作成します Original: creates an alias of an existing namespace The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |