Espaces de noms
Variantes
Affichages
Actions

Typedef declaration

De cppreference.com
< cpp‎ | language

 
 
Langage C++
Sujets généraux
Contrôle de flux
Instructions conditionnelles
Instructions d'itération
Instructions de saut
Fonctions
déclaration de fonction
expression lambda
fonction générique
spécificateur inline
spécification d'exception (obsolète)
spécificateur noexcept (C++11)
Exceptions
Espaces de noms
Types
spécificateur decltype (C++11)
Qualificatifs
qualificatifs const et volatile
qualificatifs de stockage
qualificatif constexpr (C++11)
qualificatif auto (C++11)
qualificatif alignas (C++11)
Initialisation
Littéraux
Expressions
opérateurs alternatifs
Utilitaires
Types
déclaration typedef
déclaration d'alias de type (C++11)
attributs (C++11)
Jette
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversions implicites
conversion const_cast
conversion static_cast
conversion dynamic_cast
conversion reinterpret_cast
conversions style C et style fonction
Allocation de mémoire
Classes
Qualificatifs spécifiques aux membres de classe
Fonctions membres spéciales
Modèles
classes génériques
fonctions génériques
spécialisation de modèles
paquets de paramètres (C++11)
Divers
Assembleur
 
La déclaration typedef fournit un moyen de créer un alias qui peuvent être utilisés n'importe où au lieu d'un nom de type (éventuellement complexe) .
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.

Sommaire

[modifier] Syntaxe

typedef type_declaration;

[modifier] Explication

La déclaration qui suit le mot-clé typedef est par ailleurs une déclaration de type normal (sauf que les spécificateurs de type d'autres, par exemple static, ne peut pas être utilisé). Il peut déclarer qu'un ou plusieurs indentifiers sur la même ligne (par exemple int et un pointeur vers int), il peut décider de tableau et les types de fonctions, les pointeurs et les références, les types de classe, etc Chaque identifiant introduit dans cette déclaration devient un typedef-nom plutôt qu'un objet qu'elle deviendrait si la typedef mot-clé a été retirée .
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.
Les noms typedef-sont des alias pour les types existants, et ne sont pas des déclarations de types nouveaux. Typedef peut pas être utilisé pour changer la signification d'un nom de type existant (y compris un nom de typedef-). Une fois déclaré, un nom de typedef-ne peut être redéclaré de se référer au même type nouveau. Noms typedef sont en vigueur dans le périmètre où elles sont visibles: des fonctions différentes ou des déclarations de classe peut définir des types de noms identiques avec une signification différente .
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.

[modifier] Mots-clés

typedef

[modifier] Exemple

// 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;
};

[modifier] Voir aussi

alias de type fournir les mêmes fonctionnalités que typedefs en utilisant une syntaxe différente, et sont également applicables aux noms de modèle .
Original:
alias de type 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.