Template class pointer c++ declaration

前端 未结 5 1786
误落风尘
误落风尘 2021-01-30 23:42
template 
class Node
{...};

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

Will fail to compile I have to to declare the

5条回答
  •  时光说笑
    2021-01-31 00:09

    Whenever you create any kind of object (including pointers) in C++, the full type of the object must be known. There is no such type in your code as Node, so you can't create instances of pointers to it. You need to rethink how you are designing and writing your code.

提交回复
热议问题