Compiler Error C2273
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2273.
type' : illegal as right side of '->' operator
A type appears as the right operand of a -> operator.
This error can be caused by trying to access a user-defined type conversion. Use the keyword operator between -> and type.
The following sample generates C2273:
// C2273.cpp
struct MyClass {
operator int() {
return 0;
}
};
int main() {
MyClass * ClassPtr = new MyClass;
int i = ClassPtr->int(); // C2273
int j = ClassPtr-> operator int(); // OK
}
Show: