开发者

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

开发者 https://www.devze.com 2023-01-26 00:15 出处:网络
template <class T> class ListRemake { ... 开发者_C百科friend ostream& operator << (ostream& out, const ListRemake& obj);
template <class T>
class ListRemake
{
    ...
开发者_C百科    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.


Replace

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

with

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


The error is telling you that ListRemake is a template and therefore you need to instantiate it to use it as a type (what you are doing in the << operator).

0

精彩评论

暂无评论...
验证码 换一张
取 消