Typedef declaration
Aus cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
Der typedef Erklrung gibt einen Weg, um einen Alias, die berall an Stelle eines (mglicherweise komplexen) Typnamen verwendet werden knnen .
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.
Syntax
typedef type_declaration;
|
|||||||||
Erklrung
Die Erklrung, die das Schlsselwort
typedef folgt, ist ansonsten ein normales Typdeklaration (auer dass andere Typspezifizierer, zB static, knnen nicht verwendet werden). Es kann eine oder mehrere indentifiers auf der gleichen Linie (zB int und einen Zeiger auf int) deklariert, kann es erklren, Array und Funktionstypen, Zeiger und Referenzen, Klasse-Typen, etc. Jeder Bezeichner in dieser Deklaration eingefhrt wird ein typedef-Namen statt als ein Objekt, dass es sich, wenn das Schlsselwort typedef wurde entfernt .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.
Die typedef-Namen sind fr bestehende Typen und sind nicht Deklaration von neuen Arten. Typedef kann nicht verwendet werden, um die Bedeutung eines bestehenden Namen (einschlielich einer typedef-name) ndern. Einmal erklrt, kann ein typedef-name nur neu deklariert, um auf die gleiche Art wieder zu beziehen. Typedef-Namen sind nur wirksam, in dem Bereich, in dem sie sichtbar sind: verschiedene Funktionen oder Klassen Erklrungen knnen identische Namen mit unterschiedlichen Bedeutung zu definieren .
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.
Keywords
Beispiel
// 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;
};
Siehe auch
Typ-Aliasnamen bieten die gleiche Funktionalitt wie typedefs mit einer anderen Syntax und gelten auch fr die Template-Namen .
Original:
Typ-Aliasnamen 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.