錯誤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':使用類模板需要模板參數列表。

2 个解决方案

#1


0  

Replace

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

with

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

#2


0  

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).

錯誤告訴您ListRemake是一個模板,因此您需要將其實例化以將其用作類型(您在< <運算符中執行的操作)。< p>


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/11/21/72553b449f7748079236b27aaf8acc35.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com