Expand|Select|Wrap|Line Numbers
- class Complex
- {
- double re;
- double im;
- public:
- Complex();
- Complex( const double &r, const double &i );
- Complex( const double &d );
- friend ofstream &operator<<( ofstream &stream, const Complex &c );
- [other stuff]
- };
Expand|Select|Wrap|Line Numbers
- ofstream ofs( "file.txt" );
- ofs << 1;
I could fix the problem in one of the following ways:
1. Remove operator<< from Complex.
2. Remove constructor Complex( const double &d ) from Complex.
3. Write ofs.basic_ostream<char, char_traits<char>>::operator<<( 1 ) instead of ofs << 1.
But nothing of the above seems acceptable. I can't believe things are really this screwed up, it doesn't seem like I'm doing anything wrong. Any suggestions?