Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
The following sample shows that a tracking reference cannot be used as a unary take-address operator.
Example
// tracking_reference_unary.cpp
// compile with: /clr
using namespace System;
ref struct R {
static R^ operator%(R ^r) { // C2805 can't declare unary operator%()
return nullptr;
}
static int operator&(R ^r) { // can declare a unary operator&()
return 1;
}
};
int main() {
int i;
int* pi1 = &i; // OK: C++ address of operator&()
int* pi2 = %i; // ERROR: No managed address of operator%()
int^ hi = %i; // ERROR: No managed address of operator%()
}