简体   繁体   中英

Can't use a struct(with template) inside a class

I made a node struct with a template:

template <typename T>
struct Node{
        T data;
        Node* next;
        Node* prev;
};

It compiles fine but when I try to use it inside a class it gives me the error: invalid use of template-name 'Node' without an argument list

In another class' context, you need to add a template parameter instead of using plain Node* :

struct B
{
  Node<int>* next;
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM