単純型名

単純型名は単純型の名前です。 つまり、ポインター、参照、配列または関数ポインターではない型です。

class-name
[ :: ] nested-name-specifier type-name
[ :: ] nested-name-specifier template template-id 
char 
wchar_t 
bool 
short 
int 
long 
signed 
unsigned 
float 
double 
void 
auto 
decltype ( expression )

解説

単純型名は、名前空間または包含クラスを示す nested-name-specifier で修飾することもできます。

int  // simple type name
unsigned int  // combination of simple type names 
MyClass  // a class type
class MyClass  // class is optional when using the type name
struct MyStruct  // the keyword struct is optional in C++
enum MyEnum  // the keyword enum is optional in C++
::MyClass  // type name at global scope
Outer::Inner  // nested type name
::Outer::Inner  // nested type names with global scope operator
MyTemplate<int>  // a class template
Outer::Inner<int> // an inner class template
Outer<char>::Inner<int>  // an inner class template of a template class
::template MyTemplate<int>  // using the template keyword
typename MyClass  // the typename keyword (only in a template definition)

次の表に、単純型名を組み合わせて使用する方法を示します。

型名の組み合わせ

組み合わせ

コメント

int

long または short の一方だけ

型 int は型 long int を意味します。

long

int または double

型 long は型 long int を意味します。

short

int

型 short は型 short int を意味します。

signed

char、short、int、または long

型 signed は signed int を意味します。 signed char 型のオブジェクトおよび符号付き整数型のビット フィールドの最上位ビットは符号ビットとして扱われます。

unsigned

char、short、int、または long

型 unsigned は unsigned int を意味します。 unsigned char 型のオブジェクトおよび符号なし整数型のビット フィールドの最上位ビットは符号ビットとして扱われません。

参照

関連項目

C++ 型指定子

auto キーワード (型推論)

decltype 型指定子