![](/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.