using struct template in template class implementation

前端 未结 1 1291
庸人自扰
庸人自扰 2021-01-28 17:32

I am trying to learn templates usage in c++. I have created a struct node which I am using in queue class implementation but I am getting compiler error: Error\" expected type s

相关标签:
1条回答
  • 2021-01-28 18:12

    Your new has a syntax error.

    qnode<T>* temp = new qnode;
    

    should be

    qnode<T>* temp = new qnode<T>();
    

    Remember, a template class without template parameters is meaningless to the compiler. Whenever you type qnode (after the initial declaration), you need to type its template parameters as well!

    0 讨论(0)
提交回复
热议问题