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;
}
我已經試過了語法的各種排列,並且似乎沒有任何工作,搜索似乎並沒有幫助或者(也許這是不被廣泛使用了?我覺得它幫助我分裂和工作大班更有效......)。
當我說編譯器對屬性的原型沒有問題時,我的意思是如果我嘗試編譯時將被實現註釋掉(原型仍然存在),編譯器「成功」,然後連接時有心臟病發作。