Reputation: 27
I have a template and I can't overload operator >> from cout.
template <class C> class Fract {
/*some fields*/
friend std::ostream& std::operator<<(std::ostream& out, Fract f);
};
When I write it, gcc (CodeBlocks) write me, that this function isn't template (non-template), but how I know, template scope is spread from { to }. How is it? I try other code:
template <class C> class Fract {
/*some fields*/
std::ostream& std::operator<<(Fract f);
};
And it isn't work. I think I must use something like that:
std::ostream<C>& std::operator<<(Fract f);
But I can't write it right. Can you help me?
UPD: Thank you, in real programm this mistakes aren't present!
Upvotes: 0
Views: 101