First of all, item = item is probably not what you want. Don't give your member variables the same name as your function parameters. Call your member variable m_item or something to distinguish it, then write this as m_item = item;. Otherwise it doesn't do what you think it does.
Two things:
1) What is T there? Are you already inside the definition of a template? If you write this:
Code:
// foo.cpp
#include "Node.h"
Node<T> *something = new Node(nullptr);
then this won't compile, because what is T? On the other hand, if you write this:
Code:
template<typename T>
void myfunction() {
Node<T> *something = new Node(nullptr);
}
This will work because now T is defined. It is whatever type you parameterized myfunction with. For example:
Code:
myfunction<int>(); // T = int, function creates a Node<int>
2) You wrote Node<T> *something = new
Node(nullptr);. In the underlined part, you haven't specified the template parameter. Is it a new Node<int>? a new Node<double>? A new Node<Node<Node<double>>>? You have to specify. Most likely what you want is this:
Code:
Node<T> *something = new Node<T>(anotherNode->item);
Wow. No. For starters, typeid does not actually do anything at compile time. It's a runtime function. typeid, despite its name, doesn't actually give you a Type. It gives you a
structure that
describes a type. A structure, that you can manipulate / query at runtime. Definitely not what you want.