Typedef declaration
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
typedef宣言はどこにも(おそらく複素数)型名の代わりに使用することができる別名を作成する方法を提供します.
Original:
The typedef declaration provides a way to create an alias that can be used anywhere in place of a (possibly complex) type 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.
目次 |
[編集] 構文
typedef type_declaration;
|
|||||||||
[編集] 説明
キーワードtypedefに続く宣言ではそれ以外の場合は、通常の型宣言(そのほかの型指定子を除いて、例えばstatic、使用することはできません)です。それは、同じ行(例えば、intとintへのポインタ)上の1つまたは多数のindentifiersを宣言することが、この宣言で導入されたすべての識別子がtypedef名となり、むしろ配列と関数型、ポインタと参照、クラスの種類などを宣言してもよいキーワードtypedefが削除された場合は、それがなるとはオブジェクトより.
Original:
The declaration that follows the keyword typedef is otherwise a normal type declaration (except that other type specifiers, e.g. static, cannot be used). It may declare one or many indentifiers on the same line (e.g. int and a pointer to int), it may declare array and function types, pointers and references, class types, etc. Every identifier introduced in this declaration becomes a typedef-name rather than an object that it would become if the keyword typedef was removed.
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.
typedef名は、既存の型の別名であり、新しい型の宣言ではありません。 typedefは、既存の型名(typedef名を含む)の意味を変更するために使用することはできません。いったん宣言typedef名は、再び同じ型を参照するために再宣言することができる。 typedef名は、彼らが表示されているスコープ内でのみ有効です:別の関数やクラスの宣言は別の意味で同じ名前のタイプを定義するかもしれません.
Original:
The typedef-names are aliases for existing types, and are not declarations of new types. Typedef cannot be used to change the meaning of an existing type name (including a typedef-name). Once declared, a typedef-name may only be redeclared to refer to the same type again. Typedef names are only in effect in the scope where they are visible: different functions or class declarations may define identically-named types with different meaning.
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.
[編集] キーワード
[編集] 例
// simple typedef typedef unsigned long ulong; // the following two objects have the same type unsigned long l1; ulong l2; // more complicated typedef typedef int int_t, *intp_t, (&fp)(int, ulong), arr_t[10]; // the following two objects have the same type int a1[10]; arr_t a2; // common C idiom to avoid having to write "struct S" typedef struct {int a; int b;} S; // the following two objects have the same type struct {int a; int b;} s1; S s2; // error: conflicting type specifier // typedef static unsigned int uint; // std::add_const, like many other metafunctions, use member typedefs template< class T> struct add_const { typedef const T type; };
[編集] 参照
型の別名異なる構文を使用してのtypedefと同じ機能を提供し、また、テンプレート名に適用されます.
Original:
型の別名 provide the same functionality as typedefs using a different syntax, and are also applicable to template names.
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.