The Wayback Machine - https://web.archive.org/web/20180228110212/http://ja.cppreference.com:80/w/cpp/language/namespace
名前空間
変種
操作

Namespaces

提供: cppreference.com
< cpp‎ | language

 
 
C++言語
一般的なトピック
フロー制御
条件付き実行文
繰り返し文 (ループ)
ジャンプ文
関数
関数宣言
ラムダ関数宣言
inline 指定子
例外仕様(廃止予定)
noexcept 指定子(C++11)
例外
名前空間
名前空間宣言
指定子
decltype(C++11)
auto(C++11)
alignas(C++11)
記憶域期間指定子
初期化
代替表現
リテラル
ブーリアン - 整数 - 浮動小数点
文字 - 文字列 - nullptr(C++11)
ユーザ定義(C++11)
ユーティリティ
アトリビュート(C++11)
typedef 宣言
型エイリアス宣言(C++11)
キャスト
暗黙の変換 - 明示的な変換
static_cast - dynamic_cast
const_cast - reinterpret_cast
メモリ確保
クラス
クラス固有の関数特性
特別なメンバ関数
テンプレート
その他
 
名前空間は、大規模なプロジェクトで、名前の衝突を防止するための方法を提供する.
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.
名前空間ブロック内で宣言されたシンボルは、別のスコープで同じ名前のシンボルに間違われてからそれらを防ぐという範囲に配置されている.
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.
同じ名前の名前空間の宣言が複数あれば、すべてのそのような宣言からすべてのシンボルを含む名前空間で、その結果、許可されてい.
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.

目次

[編集]構文

namespacens_name { declarations } (1)
inlinenamespacens_name { declarations } (2) (C++11およびそれ以降)
ns_name::name (3)
usingnamespacens_name; (4)
usingns_name::name; (5)

[編集]説明

名前空間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.
名前空間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.
ネームスペースのコンテンツにアクセスするための標準的な方法#.
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.
#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.
#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.

[編集]

この例では、すでに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.

#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.
[edit]
close