简体   繁体   English

错误C2955:“ ListRemake”:使用类模板需要模板参数列表

[英]error C2955: 'ListRemake' : use of class template requires template argument list

template <class T>
class ListRemake
{
    ...
    friend ostream& operator << (ostream& out, const ListRemake& obj);
};

template <class T>
ostream& operator << (ostream& out, const ListRemake& obj)
{
    for (int i = 0; i < obj.size; i++)
        out << obj[i] << '\n';
    return out;
}

Gives the error C2955: 'ListRemake' : use of class template requires template argument list. 给出错误C2955:'ListRemake':使用类模板需要模板参数列表。

该错误告诉您ListRemake是模板,因此您需要实例化它以将其用作类型(在<<操作符中执行的操作)。

Replace 更换

ostream& operator << (ostream& out, const ListRemake& obj)

with

ostream& operator << (ostream& out, const ListRemake<T>& obj)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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