2
什麼是適當的方式來獲得在下面的代碼non-handle
類型:C++ CLI句柄類型
template <typename Type> ref class SuperClass
{
public:
void Method()
{
Type x = gcnew ???? (...);
// I want it to be instantiated into 'String^ x = gcnew String(...).
// Is there a way to "dereference" the handle type in C++ \ CLI ?
}
};
SuperClass<String^> superClass;
superClass.Method(); // <---- Won't compile
此外,手柄式的使用作爲模板參數是強制性(這是更大的一部分例如,我不能簡單地將模板類型更改爲String
而不是String^
)。
我最後的評論實際上告訴我不能避免傳遞**手柄式**作爲模板參數。但是,謝謝:) –
請檢查我對代碼的編輯是否適合您。 – Superman
它沒有:)但是,你把我推向了我的案例的正確解決方案,再次感謝。 –