Espaces de noms
Variantes
Affichages
Actions

Qualificatifs const et volatile

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
 
  • const - définit que le type est constant .
  • volatile - définit que le type est volatil .
  • mutable - définit qu'un membre d'une classe n'affecte pas l'état visible de l'extérieur de la classe. Les membres mutable peuvent être modifiés dans les classes constantes, cette propriété est en effet ignorée pour les membres mutable.

[modifier] Explication

Remarque:cv-qualificatifs et cv-prescripteurs (liste ci-dessus) ne sont pas les mêmes thing.
la CV-qualification sont propriétés d'un type alors que cv-prescripteurs sont fonction de la langue de définir cv-qualifications
Original:
Note: cv-qualifiers and cv-specifiers (list above) are not the same thing.
The cv-qualifiers are properties of a type whereas cv-specifiers are language feature to define cv-qualifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cv qualificatifs définir deux propriétés de base d'un type: constness''' et de la volatilité. Un CV-Qualifier peut être l'un des suivants: 'const volatile', 'const', 'volatile' ou 'none'. const définit qu'un type est'' constant, volatile définit que le type est' volatile. Type non-constante et non volatile n'a pas de restrictions supplémentaires, tandis que constante et volatile signifie ce qui suit:
Original:
Cv-qualifiers define two basic properties of a type: constness and volatility. A cv-qualifer can be one of the following: 'const volatile', 'const', 'volatile' or 'none'. const defines that a type is constant, volatile defines that the type is volatile. Non-constant and non-volatile type has no additional restrictions, whereas constant and volatile imply the following:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ' Constant' - l'objet ne doit pas être modifié. Essayer de le faire entraîne un comportement indéfini. Sur la plupart des compilateurs, il est temps de compilation erreur .
    Original:
    constant - the object shall not be modified. Attempt to do so results in undefined behavior. On most compilers it is compile-time error.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ' Volatile »- l'objet peut être modifié par des moyens non détectables par le compilateur et donc quelques optimisations du compilateur doit être désactivé .
    Original:
    volatile - the object can be modified by means not detectable by the compiler and thus some compiler optimizations must be disabled.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Il est d'ordre partiel de cv-qualifiés par l'ordre des restrictions croissantes. Le type peut dire plus ou moins cv-qualifié alors:
Original:
There is partial ordering of cv-qualifiers by the order of increasing restrictions. The type can be said more or less cv-qualified then:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • Sans réserve <const
    Original:
    unqualified < const
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Sans réserve <volatile
    Original:
    unqualified < volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Sans réserve <const volatile
    Original:
    unqualified < const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • const < const volatile
  • volatile < const volatile
Toute cv-qualifications font partie de la définition de type, donc avec différents types cv-qualifications sont toujours différents types. Par conséquent coulée est nécessaire pour correspondre à des types lors de l'affectation des variables, des fonctions d'appel, etc Seulement coulée à plus cv-qualifié type se fait automatiquement dans le cadre de <div class="t-tr-text"> les conversions implicites
Original:
implicit conversions
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
. En particulier, les conversions suivantes sont autorisées:
Original:
Any cv-qualifiers are part of the type definition, hence types with different cv-qualifications are always different types. Therefore casting is needed to match types when assigning variables, calling functions, etc. Only casting to more cv-qualified type is done automatically as part of
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ' Type non qualifié peut être converti en const
    Original:
    unqualified type can be converted to const
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ' Type non qualifié peut être converti en volatile
    Original:
    unqualified type can be converted to volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ' Type non qualifié peut être converti en const volatile
    Original:
    unqualified type can be converted to const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Type const peut être converti en const volatile
    Original:
    const type can be converted to const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Type volatile peut être converti en const volatile
    Original:
    volatile type can be converted to const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Pour convertir un moins cv-qualifié type, const_cast doit être utilisé .
Original:
To convert to a less cv-qualified type, const_cast must be used.
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

const, volatile, mutable

[modifier] Exemple