◐ Shell
clean mode source ↗

<div class="t-tr-text">C + + keywords:<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

Aus cppreference.com

<metanoindex/>

Usage

  • Deklaration einer Klasse
  • In einer Klassen-Template oder Funktions-Template, class können als Alternative zu den Typ typename Vorlagenparametern einzuführen verwendet werden .

    Original:

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

  • Wenn eine Funktion oder eine Variable existiert im Umfang mit dem Namen identisch mit dem Namen einer Klasse-Typ, kann class dem Namen Begriffsklärung vorangestellt werden, was zu einer erarbeitet Typspezifizierer

    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.

Beispiel

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
}