0
我正在使用C++/CLI,试图在头文件中声明类的原型,然后在cpp文件中实现它们。声明属性,然后再定义?
在一般的cpp中,这似乎相当普遍,但它似乎不适用于C++/CLI语法,我错过了什么?
#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;
}
我已经试过了语法的各种排列,并且似乎没有任何工作,搜索似乎并没有帮助或者(也许这是不被广泛使用了?我觉得它帮助我分裂和工作大班更有效......)。
当我说编译器对属性的原型没有问题时,我的意思是如果我尝试编译时将被实现注释掉(原型仍然存在),编译器“成功”,然后连接时有心脏病发作。