A
Amadeus W. M.
What is the difference between
friend ostream & operator<<(ostream & OUT, const Foo & f){
// output f
return OUT;
}
and
template <class X>
friend ostream & operator<<(ostream & OUT, const Foo<X> & f){
// output f
return OUT;
}
either one defined INSIDE a
template <class T>
class Foo
{
//
};
They both work, but is there a difference? The latter is a
template function inside a template class, right? I understand that part.
But why doesn't the former need template<class X> and Foo<X>& ?
I use these on a daily basis, and suddenly I felt the urge for
clarification. Thanks!
friend ostream & operator<<(ostream & OUT, const Foo & f){
// output f
return OUT;
}
and
template <class X>
friend ostream & operator<<(ostream & OUT, const Foo<X> & f){
// output f
return OUT;
}
either one defined INSIDE a
template <class T>
class Foo
{
//
};
They both work, but is there a difference? The latter is a
template function inside a template class, right? I understand that part.
But why doesn't the former need template<class X> and Foo<X>& ?
I use these on a daily basis, and suddenly I felt the urge for
clarification. Thanks!