error C2955: 'ListRemake' : use of class template requires template argument list
-
27-09-2019 - |
Question
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.
Solution
Replace
ostream& operator << (ostream& out, const ListRemake& obj)
with
ostream& operator << (ostream& out, const ListRemake<T>& obj)
OTHER TIPS
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).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow