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

Caleb Jares
  • 6,163
  • 6
  • 56
  • 83

2 Answers2

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

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
0

Replace

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

with

ostream& operator << (ostream& out, const ListRemake<T>& obj)
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
  • I get a linker error: unresolved error: Error 1 error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class ListRemake const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$ListRemake@N@@@Z) referenced in function _main – Caleb Jares Nov 21 '10 at 21:54
  • @cable: Are you trying to separate declarations and definitions in different files? That doesn't work with templates. – fredoverflow Nov 21 '10 at 21:58
  • no it's all in the same file with main() I pasted the whole code on pastebin if you want to take a look http://pastebin.com/E9VkcDNH – Caleb Jares Nov 21 '10 at 22:02
  • 2
    @cable you miss a "template" for your friend declaration... Otherwise it declares a nontemplate function... – Johannes Schaub - litb Nov 21 '10 at 22:07