Overloading the << operator with template class [duplicate]

  c++, class, overloading, templates

As the title says I want to overload the << operator with a template class

but keep getting a "does not match any template declaration"

eg. in the .h file

template <class T>
class foo
{
friend ostream & operator<< <T>(ostream &output , foo<T> & F);

}

and in the .cpp file

template <class T>
ostream & operator<< <T>(ostream &output , foo<T> & F)
{

output<<"whatever";

return output;
}

How would I possible do that as I’m still learning to this.

Source: Windows Questions C++

LEAVE A COMMENT