Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Nazwa typu prostego jest nazwą typu prostego. Oznacza to typ, który nie jest wskaźnikiem, odwołaniem, tablicą lub wskaźnikiem na funkcję.
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 )
Uwagi
Nazwa typu prostego może być kwalifikowana za pomocą specyfikatora zagnieżdżonej nazwy, wskazującego na przestrzeń nazw lub klasę, która zawiera ten typ.
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)
W poniższej tabeli przedstawiono, jak nazwy typów prostych mogą być razem używane.
Kombinacje nazw typów
Typ |
Może pojawić się z |
Komentarze |
---|---|---|
int |
long lub short, ale nie oba. |
Typ int implikuje typ long int. |
long |
int lub double |
Typ long implikuje typ long int. |
short |
int |
Typ short implikuje typ short int. |
signed |
char, short, int lub long |
Typ signed implikuje signed int.Najbardziej znaczący bit obiektów typu signed char i pola bitowe typów całkowitych ze znakiem są używane jako bit znaków. |
unsigned |
char, short, int lub long |
Typ unsigned implikuje unsigned int.Najbardziej znaczący bit obiektów typu unsigned char i pola bitowe typu całkowitego bez znaku nie są traktowane jako bit znaku. |