Template Function in eMbedded Visual C ++ 4.0 for Windows CE

Does eMbedded Visual C ++ 4.0 (SP4) template function support? I get an error when trying to compile code that works fine in Visual C ++ 6.0.

Here is my template function that compiles:

template<class NodeType>
NodeType* MyFunction()
{
    // ... do stuff
    return new NodeType("foo"); // return a new class instance of type NodeType
}

Using the template function:

MyClass *myOjb = MyFunction<MyClass>(); // this is causing an error

Compilation errors:

error C2275: 'MyClass' : illegal use of this type as an expression
                         see declaration of 'MyClass'
error C2059: syntax error : ')'

Is there any compiler I need to change? How do I compile it?

+3
source share
1 answer

Found the answer here .

"It works great when the template function is not a member of the class. Oh, well, I think I will have to leave it a global function."

+3
source

All Articles