![](/img/trans.png)
[英]Does Visual Studio 2005/08/10 replace Embedded Visual C++ 4.0?
[英]Template function in eMbedded Visual C++ 4.0 for Windows CE
eMbedded Visual C++ 4.0 (SP4) 是否支持模板功能? 當我嘗試編譯在 Visual C++ 6.0 中運行良好的代碼時出現錯誤。
template<class NodeType>
NodeType* MyFunction()
{
// ... do stuff
return new NodeType("foo"); // return a new class instance of type NodeType
}
MyClass *myOjb = MyFunction<MyClass>(); // this is causing an error
error C2275: 'MyClass' : illegal use of this type as an expression
see declaration of 'MyClass'
error C2059: syntax error : ')'
我需要更改一些編譯器開關嗎? 我如何讓它編譯?
在這里找到了答案。
“當模板 function 不是 class 成員時,它可以正常工作。哦,好吧,我想我必須將其保留為全局 function。”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.