I’m using C++/CLI, trying to declare a class’ prototypes in a header file, and then implement them in a cpp file.
In general cpp this seems fairly common, but it doesn’t seem to work with the C++/CLI syntax, what am I missing?
#using <mscorlib.dll>
using namespace System;
public ref class AClass {
public:
static Boolean GetSomething (); // Compiler is fine with this
static property Boolean Something { Boolean get (); } // Compiler doesn't complain about this
};
// Compiler is not cool with this
property Boolean AClass::Something {
Boolean get () { return true; }
}
// Compiler is fine with this
Boolean AClass::GetSomething () {
return true;
}
I’ve tried various permutations of the syntax, and nothing seems to work, searching doesn’t seem to help either (maybe this isn’t widely used anymore? I find it helps me split up and work with large classes more effectively…).
When I say that the compiler is fine with the prototype of the property, I mean that if I try and compile with the would-be implementation commented out (and the prototype still present), the compiler “succeeds” and then has a heart attack while linking.
You need to define the property getter just like a normal function definition.