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).
精彩评论