How to: Cannot Use Tracking References and Unary "Take-Address" Operator
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%()
}