Template class pointer c++ declaration

Viewed 55734
template <typename T>
class Node
{...};

int main
{
    Node* ptr;
    ptr = new Node<int>;
}

Will fail to compile I have to to declare the pointer as

Node<int>* ptr;

Why do I have to specify the type when declaring a pointer I haven't created the class yet, why does the compiler have to know what type it will be pointing to. And is it not possible to create a generic pointer and decide afterwards what type I want to assign it.

5 Answers
Related