C
Chase Bradford
Hey all
I have a class Foo, and I'm trying to overload the << operator for both
the ostream and ofstream for it. This way I should have two seperate
formats for output, one for files and another for the screen. Right now the
two declarations are:
std:fstream& operator<<( std:fstream &fos, const Foo &theClass);
std:stream& operator<<( std:stream &fos, const Foo &theClass);
The problem is that I keep getting this error with G++
choosing 'std::basic_ostream<_CharT, _Traits>& std:perator<<
(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT,
_Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>,
_Alloc = std::allocator<char>]' over 'std:fstream& operator<<(
std:fstream &fos, const Foo &theClass)'
because worst conversion for the former is better than the worst conversion
for the latter
Googling for this error didn't turn up anything productive, so I was
wondering if it is possible to even do this?
Thanks.
I have a class Foo, and I'm trying to overload the << operator for both
the ostream and ofstream for it. This way I should have two seperate
formats for output, one for files and another for the screen. Right now the
two declarations are:
std:fstream& operator<<( std:fstream &fos, const Foo &theClass);
std:stream& operator<<( std:stream &fos, const Foo &theClass);
The problem is that I keep getting this error with G++
choosing 'std::basic_ostream<_CharT, _Traits>& std:perator<<
(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT,
_Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>,
_Alloc = std::allocator<char>]' over 'std:fstream& operator<<(
std:fstream &fos, const Foo &theClass)'
because worst conversion for the former is better than the worst conversion
for the latter
Googling for this error didn't turn up anything productive, so I was
wondering if it is possible to even do this?
Thanks.