Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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%()
}