二胖呀 』 2021-02-03 14:45 采纳率: 66.7%
浏览 62
已结题

这个报错是什么意思?怎么解决

invalid use of template-name 'Circular' without an argument list

这个报错怎么解决

template<class T>
class ChainNode; 
template<class T>
class Circular {
    public:
        Circular() {last = 0;}
        ~Circular();
        //Circular<T>& Create_LinkList_Head(int n); 
        int Length() const; 
        bool Find(int k, T& x) const; 
        int Search(const T& x) const; 
        Circular<T>& Delete(int k, T& x); 
        Circular<T>& Insert(int k, const T& x);
        //void Output(ostream& out) const;
    private:
        ChainNode<T> *last;  // pointer to last node
    };
template<class T>
class ChainNode{
    friend Circular<T>;
    private:
    T data;//编号    密码通过数组存储 
    ChainNode<T> *link;
    };
template<class T>
Circular<T>::~Circular(){// 链表的析构函数,用于删除链表中的所有节点
    if (!last) return;         // list is empty
    ChainNode<T> *current = last->link,  *next; 
    while (current != last) {
        next = current->link;
        delete current;
        current = next;
        }
    delete last;
    };    
Circular<int>& Create_LinkList_Head(int n){// 初始单向循环链表化链表——头插法
    Circular<int>* head, *node, *end;
    head = new Circular;//这一行报错
    head->next = head;
    end = head;
    for (int i= 0;i<=n;i++){
        node = new Circular;
        node->data = i+1;
        end->next = node;
        end = node;
        cin >> i+1;
    }
    end->next = head;
    return head;
    };

  • 写回答

1条回答 默认 最新

  • wlj1234 2021-02-07 12:42
    关注

    调用模板要把参数类型加上

    head = new Circular<int>();
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月16日
  • 已采纳回答 9月8日

悬赏问题

  • ¥15 写uniapp时遇到的问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流