Look at it this way:
1 2 3 4 5
|
template <class Type>
nodeType<Type> *createNewNode(Type)
{
return new nodeType<Type>;
}
|
Let's say you want to instantiate this function using, say, int, as the template argument (Actually, I didn't think you could use int, because int is a basic type, not a class, but your code seems to accept it). So, the expansion of the template would be:
1 2 3 4
|
nodeType<int> *createNewNode(int)
{
return new nodeType<int>;
}
|
This is a function call that takes an int as an argument and returns a nodeType<int> as a return value. Notice the argument itself is never used.
In the expanded form, the function would be called like this:
1 2
|
nodeType *newNode;
newNode = createNewNode(5);
|
You have to pass an int argument (in this example it's 5) to the function.
If you took your statement
newNode = factory.createNewNode(Type); //create the new node
And instantiated it for ints, it would be:
newNode = factory.createNewNode(int); //create the new node
Notice, you are passing a type (int) to a function that requires a value. That's why it doesn't work. When you changed it to
factory.createNewNode(int())
you were actually calling a constructor to create an int object which can be correctly passed to the function.
So, the question I have for you is, do you need to pass an argument to the createNewNode function, or do you want to get rid of the function and call it like
newNode = factory.createNewNode<Type>(); //create the new node