Namensräume
Varianten
Aktionen

Member access operators

Aus cppreference.com
< cpp‎ | language

 
 
Sprache C++
Allgemeine Themen
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Flusskontrolle
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bedingte Ausführung Aussagen
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Iterationsanweisungen
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Gehe Aussagen
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktion Erklärung
Lambda-Funktion Erklärung
Funktions-Template
inline-Spezifizierer
Exception-Spezifikationen (veraltet)
noexcept Spezifizierer (C++11)
Ausnahmen
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
Specifiers
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv Planer
Lagerdauer Planer
constexpr Spezifizierer (C++11)
auto Spezifizierer (C++11)
alignas Spezifizierer (C++11)
Initialisierung
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literale
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressions
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
alternative Darstellungen
Utilities
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
Typ Aliasdeklaration (C++11)
Attribute (C++11)
Wirft
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
impliziten Konvertierungen
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-Stil und funktionale Besetzung
Speicherzuweisung
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Class-spezifische Funktion Eigenschaften
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
explizit (C++11)
statisch
Besondere Member-Funktionen
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Templates
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Klassen-Template
Funktions-Template
Template-Spezialisierung
Parameter Packs (C++11)
Verschiedenes
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Inline Montage
 
Greift ein Mitglied eines Objekts .
Original:
Accesses a member of an object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operator name Syntax Over​load​able Prototype examples (for class T)
Inside class definition Outside class definition
array subscript a[b] Yes R& T::operator[](const T2& b); N/A
indirection (variable pointed to by a) *a Yes R& T::operator*(); R& operator*(T &a);
address of &a Yes R* T::operator&(); R* operator&(T &a);
member of object a.b No N/A N/A
member of pointer a->b Yes R* T::operator->() N/A
pointer to member of object a.*b No N/A N/A
pointer to member of pointer a->*b Yes R* T::operator->*(R) R* T::operator->*(T, R)
'Notes'
Original:
Notes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • Wie bei den meisten benutzerdefinierten Überlastungen, sollte Rückgabetypen überein Rückgabetypen von den eingebauten Operatoren, so dass die benutzerdefinierten Operatoren in der gleichen Weise wie die built-ins verwendet werden kann. Jedoch in einer benutzerdefinierten Operator Überlast kann jeder Typ als Rückkehr-Typ (einschließlich void) verwendet werden. Eine Ausnahme ist operator->, die einen Zeiger zurückgeben muss .
    Original:
    As with most user-defined overloads, return types should match return types provided by the builtin operators so that the user-defined operators can be used in the same manner as the built-ins. However, in a user-defined operator overload, any type can be used as return type (including void). One exception is operator->, which must return a pointer.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Erklärung

Feldindex Operator bietet Zugriff auf die Elemente in das interne Array
Original:
array subscript operator provides access to the elements in the internal array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Indirektion, Mitglied der Zeiger und Zeiger auf ein Element des Zeigers die Betreiber Zeiger Semantik für jedes Objekt .
Original:
indirection, member of pointer and pointer to member of pointer operators provide pointer semantics for any object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Mitglied der Zeiger und Zeiger auf ein Element des Zeigers Operatoren liefern einen Zeiger auf das eigentliche Objekt, die für Mitglied Zugang verwendet werden .
Original:
member of pointer and pointer to member of pointer operators return a pointer to the actual object which will be used for member access.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Built-in Index-Operator

Für jeden Objekttyp T (möglicherweise cv-qualifiziert) beteiligt sich die folgende Funktion Signatur in Überlast-Auflösung:
Original:
For every object type T (possibly cv-qualified), the following function signature participates in overload resolution:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
T& operator[](T*, std::ptrdiff_t);
T& operator[](std::ptrdiff_t, T*);
Die nicht-Zeiger Operand kann jeder Ausdruck von integrierten oder ohne Bereichseinschränkung Aufzählungstyp sein, ist es implizit konvertiert um std::ptrdiff_t. Der Ausdruck A[B] ist genau identisch mit dem Ausdruck *(A+B), das heißt, wird der Zeiger Operanden (das ein Ergebnis-Array zu Zeiger Konvertierung und in dessen mit einem Element von einigen Array oder ein über das Ende hinweisen) einzustellenden Punkt, an ein anderes Element des gleichen Array wird nach den Regeln der Zeigerarithmetik und dann dereferenziert .
Original:
The non-pointer operand may be any expression of integral or unscoped enumeration type, it is implizit konvertiert to std::ptrdiff_t. The expression A[B] is exactly identical to the expression *(A+B), that is, the pointer operand (which may be a result of array-to-pointer conversion, and which must point to an element of some array or one past the end) is adjusted to point at another element of the same array, following the rules of Zeigerarithmetik, and is then dereferenced.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>
 
int main()
{
    int a[4] = {1,2,3,4};
    int* p = &a[2];
    std::cout << p[1] << p[-1] << 1[p] << (-1)[p] << '\n';
}

Output:

4242

[Bearbeiten] Built-in Dereferenzierungsoperator

Für jede Art T, die entweder Objekttyp (möglicherweise cv-qualifiziert) oder Funktion Typ (nicht const-oder ref-qualifiziert) ist, beteiligt sich die folgende Funktion Signatur in Überlast-Auflösung:
Original:
For every type T that is either object type (possibly cv-qualified) or function type (not const- or ref-qualified), the following function signature participates in overload resolution:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
T& operator*(T*);
Der Operand des eingebauten Dereferenzierungsoperator ist ein Zeiger auf Objekt oder eine Funktion, und das Ergebnis ist die lvalue, dass der Zeiger gerade befindet. Beachten Sie, dass ein Zeiger auf unvollständigen Typ dereferenziert werden können, zB bei der Initialisierung eine Referenz .
Original:
The operand of the built-in indirection operator is a pointer to object or function, and the result is the lvalue that the pointer is pointing at. Note that a pointer to incomplete type can be dereferenced, e.g. when initializing a reference.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>
int f() { return 42; }
int main()
{
    int n = 1;
    int* pn = &n;
 
    int& r = *pn;  // lvalue can be bound to a reference
    int m = *pn;   // indirection + lvalue-to-rvalue conversion
 
    int (*fp)() = &f;
    int (&fr)() = *fp; // function lvalue can be bound to a reference 
}


[Bearbeiten] Built-in Adreßoperator

Der Operand des eingebauten operator& ist entweder ein L-Wert Ausdruck eines beliebigen Typs oder der qualifizierten Namen einer nicht-statische Member-Funktion / object in irgendeiner Klasse. Dieser Operator nicht in Überlast Beschlussfassung teilnehmen, werden spezielle Regeln verwendet:
Original:
The operand of the built-in operator& is either an lvalue expression of any type or the qualified name of a non-static member function/object in some class. This operator does not participate in overload resolution, special rules are used:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Falls der Operand ein L-Wert Expression eines Typs ist T, operator& erzeugt und gibt eine prvalue vom Typ T* mit derselben Qualifikation cv, die an dem Objekt durch die Operanden bestimmt zeigt. Wenn der Operand hat unvollständigen Typen kann der Zeiger gebildet werden, aber wenn das unvollständigen Typ passiert eine Klasse, die eigene operator& definiert ist, ist das Verhalten undefiniert. Für die Operanden vom Typ mit benutzerdefinierten operator& kann std::addressof verwendet werden, um die wahre Zeiger zu erhalten .
Original:
If the operand is an lvalue expression of some type T, operator& creates and returns a prvalue of type T*, with the same cv qualification, that is pointing at the object designated by the operand. If the operand has incomplete type, the pointer can be formed, but if that incomplete type happens to be a class that defines its own operator&, the behavior is undefined. For the operands of type with user-defined operator&, std::addressof may be used to obtain the true pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn der Operand ist der Name einer überladenen Funktion, die Adresse kann nur angewendet werden, wenn die Überlastung durch den Kontext, also die Ergebnis von operator& verwendet, um ein Objekt zu initialisieren, in einer Besetzung Ausdruck gelöst werden kann, Links von einer Zuweisung als Funktionsparameter oder in einem Return-Anweisung .
Original:
If the operand is the name of an overloaded function, the address may be taken only if the overload can be resolved due to context, that is, the result of operator& is used to initialize an object, in a cast expression, on the left of an assignment, as a function parameter or in a return statement.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn der Operand ist ein qualifizierter Name einer nicht statischen Member, z. B. &Class::member, ist das Ergebnis ein prvalue Zeiger auf Elementfunktion oder Zeiger auf Member-Objekt des Typs T in der Klasse C. Beachten Sie, dass weder &member noch Class::member nicht einmal (&Class::member) kann verwendet werden, um einen Zeiger auf Elementfunktion zu initialisieren .
Original:
If the operand is a qualified name of a non-static member, e.g. &Class::member, the result is a prvalue pointer to member function or pointer to member object of type T in class C. Note that neither &member nor Class::member nor even (&Class::member) may be used to initialize a pointer to member.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
void f(int) {}
void f(double) {}
struct A { int i; };
struct B { void f(); };
int main()
{
    int n = 1;
    int* pn = &n; // pointer
    int A::* mp = &A::i;  // pointer to member object
    void (B::*mpf)() = &B::f; // pointer to member function
 
//    auto pf2 = &f; // error: ambiguous overloaded function type
    void (*pf)(int) = &f; // overload resolution due to initialization
    auto pf2 = static_cast<void(*)(int)>(&f); // overload resolution due to cast
}


[Bearbeiten] Built-in-Operators

Der linke Operand des eingebauten operator. und operator-> ist ein Ausdruck der kompletten Klasse Typ T (für operator.) oder Zeiger auf Klasse Typ T* (für operator->, die ausgewertet werden, bevor der Bediener aufgerufen werden kann abgeschlossen ist. Die rechte Operand ist der Name eines Mitglieds Objekt oder Member-Funktion T oder eines T die Basisklassen, zB expr.member, optional qualifizierte, zB expr.name::member, optional das Schlüsselwort vorangestellt Vorlage, zB expr.template member .
Original:
The left operand of the built-in operator. and operator-> is an expression of complete class type T (for operator.) or pointer to complete class type T* (for operator->, which is evaluated before the operator can be called. The right operand is the name of a member object or member function of T or of one of T's base classes, e.g. expr.member, optionally qualified, e.g. expr.name::member, optionally prepended by the keyword template, e.g. expr.template member.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Die Expression A->B entspricht genau (*A).B für builtin Typen. Wenn ein Benutzer-definierte operator-> vorgesehen ist, wird operator-> wieder auf den Wert, den es gibt rekursiv, bis die operator-> wird erreicht, dass gibt einen einfachen Zeiger genannt. Danach builtin Semantik diesem Zeiger angewendet werden .
Original:
The expression A->B is exactly equivalent to (*A).B for builtin types. If a user-defined operator-> is provided, operator-> is called again on the value that it returns, recursively, until the operator-> is reached that returns a plain pointer. After that, builtin semantics are applied to that pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
In dem Ausdruck expr.B
Original:
In the expression expr.B,
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
wenn B Typ T& hat, ist das Ergebnis ein lvalue T .
Original:
if B has type T&, the result is an lvalue T.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
wenn B eine statische Datenmember vom Typ T ist, ist das Ergebnis ein lvalue T Bezeichnung dieses statische Daten Mitglied .
Original:
if B is a static data member of type T, the result is an lvalue T designating that static data member.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
wenn B ein nicht-statisches Datenelement vom Typ T ist, ist das Ergebnis, wenn ein L-Wert ist ein L-Wert expr, ist das Ergebnis, wenn xWert expr ein xWert, und das Ergebnis ist ein prvalue anders angegeben. Wenn B nicht auf deklariert sein mutable Mitglied der cv-Qualifikation der Folge die Vereinigung von cv-Qualifikation expr und B. Wenn B wandelbar ist, ist die cv-Qualifikation der Folge die Vereinigung der flüchtigen Qualifikationen .
Original:
if B is a non-static data member of type T, the result is an lvalue if expr is an lvalue, the result is xvalue if expr is an xvalue, and the result is a prvalue otherwise. If B is not declared to be a mutable member, the cv-qualification of the result is the union of cv-qualifications of expr and B. If B is mutable, the cv-qualification of the result is the union of volatile-qualifications.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
wenn B ein statisches Element Funktion ist, ist das Ergebnis ein L-Wert Bezeichnen des statischen memeber Funktion. Wesentlichen expr wird ausgewertet und in diesem Fall verworfen .
Original:
if B is a static member function, the result is an lvalue designating the static memeber function. Essentially, expr is evaluated and discarded in this case.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
wenn B ein nicht-statisches Element Funktion ist, ist das Ergebnis eine besondere Art der prvalue, die nur als den linken Operanden in einem Funktionsaufruf Ausdruck verwendet werden kann, und zu keinem anderen Zweck .
Original:
if B is a non-static member function, the result is a special kind of prvalue that can only be used as the left-hand operand in a function-call expression, and for no other purpose.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
wenn B Mitglied Aufzählung ist, ist das Ergebnis ein prvalue der .
Original:
if B is a member enumeration, the result is a prvalue of the.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)
wenn B ist ein geschachtelter Typ ist das Programm mangelhafte (nicht kompiliert)
Original:
if B is a nested type, the program is ill-formed (won't compile)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)
wenn expr Nicht-Klasse skalare Art und B hat, ist der Name des Typs oder decltype specifier Benennung des gleichen Typs (minus cv-Qualifikationen), dann ist das Ergebnis ist eine spezielle Art von prvalue, die nur als den linken Operanden in einem Funktionsaufruf Ausdruck, und zu keinem anderen Zweck verwendet werden kann. Die Funktion Aufruf heißt pseudo destructor call 'es keine Argumente, kehrt void nimmt, und führt keine andere Aktion als die anfängliche Evaluation expr .
Original:
if expr has non-class scalar type and B is the type name or decltype specifier designating the same type (minus cv-qualifications), then the result is a special kind of prvalue that can only be used as the left-hand operand in a function-call expression, and for no other purpose. The function call is called pseudo destructor call', it takes no arguments, returns void, and performs no action other than initial evaluation of expr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>
template<typename T>
struct P { typedef T* ptr; };
template<typename T>
struct A {
    class B {};
    enum E {RED = 1, BLUE = 2};
    int n;
    static int sn;
    int f() { return 10+n; }
    static int fs() { return 4; }
    A(int n) : n(n) {}
 
    // keyword template needed to refer to a dependent template member
    void g() {
        T obj;
        int* p = obj.template ptr<int>;
        p->~T(); // T is int, this calls int's pseudo destructor
    }
};
template<> int A<P<int>>::sn = 2;
 
int main()
{
    A<P<int>> a(1);
    std::cout << a.n << ' '
              << a.sn << ' ' // << A::sn also works
              << a.f() << ' ' 
              << a.fs() << ' ' // A::fs() also works
              << a.RED << ' '  // nested type not allowed
//            << a.B  // nested type not allowed
              ;
}

Output:

1 2 11 4 1

[Bearbeiten] Built-in-Zeiger-auf-Member Zugang Betreiber

Der rechte Operand sowohl operator.* und operator->* ist ein Ausdruck vom Typ Zeiger auf ein Element in der Klasse T. Für operator.*, ist der linke Operand ein Ausdruck von Klasse Typ T, oder einige abgeleitete Klasse, in der T ist eindeutig zugänglich Base. Für operator->*, der linke Operand ein Zeiger auf T oder seine Basis ist .
Original:
The right operand of both operator.* and operator->* is an expression of type pointer to member in class T. For operator.*, the left operand is an expression of class type T, or of some derived class in which T is unambiguous accessible base. For operator->*, the left operand is a pointer to T or to its base.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Für jede Kombination von Typen B, D, T, wo D ist entweder gleich oder B eine Klasse von B abgeleitet und T entweder Objekt oder eine Funktion geben, beteiligt sich die folgende Funktion Signatur in Überlast-Auflösung:
Original:
For every combination of types B, D, T, where D is either the same as B or a class derived from B, and T is either object or function type, the following function signature participates in overload resolution:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
T& operator->*(B*, T D::*);
, wenn beide Operanden kann cv-qualifiziert, in welchem ​​Fall der Rückkehr Typs cv-Qualifikation der Union der ist. cv-Qualifikation der Operanden .
Original:
where both operands may be cv-qualified, in which case the return type's cv-qualification is the union of the cv-qualification of the operands.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Die Expression E1->*E2 entspricht genau (*E1).*E2 für eingebaute Typen .
Original:
The expression E1->*E2 is exactly equivalent to (*E1).*E2 for built-in types.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Für die Expression expr.*ptr
Original:
For the expression expr.*ptr,
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Wenn der dynamische Typ expr enthält nicht das Element, an dem ptr bezieht Das Verhalten ist undefiniert
Original:
If the dynamic type of expr does not contain the member to which ptr refers, the behavior is undefined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
cv-Qualifikation gelten die gleichen Regeln wie für Mitglied Zugang Betreiber mit einem zusätzlichen Regel:.. ein Zeiger auf ein Element, das zu einem veränderlichen Mitglied kann nicht verwendet werden, um das Mitglied in einer const-Objekt zu ändern .
Original:
cv-qualification rules are the same as for member access operator, with one additional rule: a pointer to member that refers to a mutable member cannot be used to modify that member in a const object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
bezieht . Wenn expr rvalue und ptr auf eine Member-Funktion mit & ref-Qualifikationsspiel ist, ist das Programm schlecht gebildet
Original:
If expr is rvalue and ptr points to a member function with & ref-qualifier, the program is ill-formed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
Wenn expr lvalue und ptr auf eine Member-Funktion mit && ref-Qualifikationsspiel ist, ist das Programm falsch gebildete
Original:
If expr is lvalue and ptr points to a member function with && ref-qualifier, the program is ill-formed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
Das Ergebnis expr.*ptr wo ptr ist ein Zeiger auf Daten Element den gleichen Wert hat Kategorie wie expr .
Original:
The result of expr.*ptr where ptr is a pointer to data member has the same value category as expr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)
Das Ergebnis expr.*ptr wo ptr ist ein Zeiger auf eine Elementfunktion specail Art, die nur als prvalue verwendet werden das linke Argument einer Funktion Anruf Ausdruck und zu keinem anderen Zweck .
Original:
The result of expr.*ptr where ptr is a pointer to member function is a specail kind of prvalue that may only be used as the left-hand argument of a function call expression and for no other purpose.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)
Wenn ptr eine Null-Zeiger-Wert ist, ist das Verhalten undefiniert
Original:
If ptr is a null pointer value, the behavior is undefined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>
struct S
{
    mutable int mi;
    int f(int n) { return mi+n; }
    S(int n) : mi(n) {}
};
struct D : public S {
        D(int n) : S(n) {}
};
 
int main()
{
    int S::* pmi = &S::mi;
    int (S::*mpf)(int) = &S::f;
 
    const S s(7);
//    s.*pmi = 10; // cannot modify through mutable
    std::cout << s.*pmi << '\n';
 
    D d(7); // base pointers work with derived object
    D* dp = &d;
    std::cout << (d.*mpf)(7) << ' '
              << (dp->*mpf)(8) << '\n';
}

Output:

7
14 15

[Bearbeiten] Standard-Bibliothek

Index-Operator wird von vielen Standard-Container-Klassen überlastet
Original:
Subscript operator is overloaded by many standard container classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
greift bestimmtes Bit
Original:
accesses specific bit
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::bitset) [edit]
bietet indizierten Zugriff auf das verwaltete Array
Original:
provides indexed access to the managed array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::unique_ptr) [edit]
Zugriff auf angegebene Zeichen
Original:
access specified character
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::basic_string) [edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::array) [edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::deque) [edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::vector) [edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::map) [edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::unordered_map) [edit]
greift ein Element von Index
Original:
accesses an element by index
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::reverse_iterator) [edit]
erhält rvalue Bezug auf indizierte Element
Original:
obtains rvalue reference to indexed element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::move_iterator)
get / set valarray Element, Scheibe, oder Maske
Original:
get/set valarray element, slice, or mask
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::valarray) [edit]
Renditen angegebenen Sub-passen
Original:
returns specified sub-match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::match_results) [edit]
Die Umleitung und Mitglied Zugang Betreiber werden von vielen Iteratoren und Smart-Pointer-Klassen überlastet
Original:
The indirection and member access operators are overloaded by many iterators and smart pointer classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
dereferenziert den Zeiger auf das verwaltete Objekt
(öffentliche Elementfunktion of std::unique_ptr) [edit]
dereferenziert den Zeiger auf das verwaltete Objekt
(öffentliche Elementfunktion of std::shared_ptr) [edit]
greift das verwaltete Objekt
Original:
accesses the managed object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::auto_ptr)
gibt einen Verweis auf dieses raw_storage_iterator
Original:
returns a reference to this raw_storage_iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::raw_storage_iterator)
dereferenziert die dekrementiert zugrunde liegenden Iterator
Original:
dereferences the decremented underlying iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::reverse_iterator) [edit]
no-op
(öffentliche Elementfunktion of std::back_insert_iterator)
no-op
(öffentliche Elementfunktion of std::front_insert_iterator)
no-op
(öffentliche Elementfunktion of std::insert_iterator)
greift auf die spitzen-to-Element
Original:
accesses the pointed-to element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::move_iterator)
erhält eine Kopie des aktuellen element
accesses ein Mitglied des aktuellen Elements
Original:
obtains a copy of the current element
accesses a member of the current element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::istream_iterator)
no-op
(öffentliche Elementfunktion of std::ostream_iterator)
erhält eine Kopie des aktuellen character
accesses ein Mitglied der aktuellen Charakter, wenn CharT Mitglieder hat
Original:
obtains a copy of the current character
accesses a member of the current character, if CharT has members
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::istreambuf_iterator)
no-op
(öffentliche Elementfunktion of std::ostreambuf_iterator)
auf den aktuellen match
accesses ein Mitglied der aktuellen Match
Original:
accesses the current match
accesses a member of the current match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::regex_iterator)
greift die aktuelle result
accesses ein Mitglied der aktuellen Ergebnis
Original:
accesses the current result
accesses a member of the current result
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion of std::regex_token_iterator)
{{{1}}}
Original:
{{{2}}}
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Siehe auch

Operator Vorrang

Common operators
Zuweisungen incrementNJdecrement Arithmetik logisch Vergleich memberNJaccess andererseits

a = b
a = rvalue
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b
a->*b
a.*b

a(...)
a, b
(type) a
? :

Special operators
static_cast wandelt einem Typ in einen anderen kompatiblen Typ
Original:
static_cast converts one type to another compatible type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
dynamic_cast wandelt virtuellen Basisklasse abgeleitet class
Original:
dynamic_cast converts virtual base class to derived class
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
const_cast wandelt Typ kompatiblen Typ mit unterschiedlichen cv qualifiers
Original:
const_cast converts type to compatible type with different cv qualifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
reinterpret_cast wandelt Typ inkompatibel type
Original:
reinterpret_cast converts type to incompatible type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
new ordnet memory
Original:
new allocates memory
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
delete freigibt memory
Original:
delete deallocates memory
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
sizeof fragt die Größe eines type
Original:
sizeof queries the size of a type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
sizeof... fragt die Größe eines Parameter Pack (seit C++11)
Original:
sizeof... queries the size of a Parameter Pack (seit C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typeid fragt die Typinformationen eines type
Original:
typeid queries the type information of a type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
noexcept prüft, ob ein Ausdruck eine Ausnahme (seit C++11)
werfen kann
Original:
noexcept checks if an expression can throw an exception (seit C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
alignof Abfragen Ausrichtungsanforderungen eines Typs (seit C++11)
Original:
alignof queries alignment requirements of a type (seit C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.