Recently, I have been working on a small project, and I could not understand anything.
I was provided with an .h file containing the class using a name template. Inside this class was a private class.
template <typename T>
class Something
{
public:
Something();
~Something();
Node* Function1(int index);
int Index(const T& id);
private:
class Node()
{
public:
T id;
};
};
The problem arose when I wanted to define the functions of the class "Something"
This is how I did it (in the .INL file)
template<typename T>
Node* Something::Function1(int index)
{
}
template<typename T>
int Something::Index(const T& id)
{
}
So, the listening part was in the definition part ... Should I tell the compiler that the return type (in this case Node *) uses a name pattern (for example:) typename Node*? What about the parameter? typename const Node&?
So basically, when do I need to indicate that a function / parameter is using a template?
Thank you for your time.