◐ Shell
clean mode source ↗

<div class="t-tr-text">C + +. Mots-clés:<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">Original:</div><div class="t-tr-dropdown-orig">C++ keywords:</div><div class="t-tr-dropdown-notes">The text has been machine-translated via [http://translate.google.com Google Translate].<br/> You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.</div></div></div></div></div> class

De cppreference.com

<metanoindex/>

D'utilisation

  • déclaration d'une classe
  • Dans un modèle de classe ou modèle de fonction, class peut être utilisé comme alternative à typename d'introduire les paramètres de modèle de type .

    Original:

    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

  • Si une fonction ou une variable existe dans la portée avec le nom identique au nom d'un type de classe, class peut être ajouté au début du nom pour la désambiguïsation, résultant en une élaboré spécificateur de type

    Original:

    If a function or a variable exists in scope with the name identical to the name of a class type, class can be prepended to the name for disambiguation, resulting in an elaborated type specifier

    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Exemple

class Foo;  // forward declaration of a class

class Bar { // definition of a class
  public:
    Bar(int i) : m_i(i) {}
  private:
    int m_i;
};

template <class T> // template argument
void qux() {
    T t;
}

int main()
{
    Bar Bar(1);
    class Bar Bar2(2); // elaborated type
}