Hello, does anyone have a clue about this error? and how to solve it?
It seems to be trivial to me, but not for the compiler. I'm using g++
4.2 on an Ubuntu Linux system:
// main()
....
std::ofstream fout;
fout.open("hell o.out");
fout<<setfill('-')<<setw(20)<<"-"<<setfill( ' ')<<endl;
fout<<"hello "; // this is line 139
....
main.cxx:89: instantiated from here
main.cxx:139: error: ISO C++ says that these are ambiguous, even
though the worst conversion for the first is better than the worst
conversion for the second:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/
ostream.tcc:735 : note: candidate 1: std::basic_ostr eam<char, _Traits>&
std::operator<< (std::basic_ost ream<char, _Traits>&, const char*) [with
_Traits = std::char_trait s<char>]
Domain.h:507: note: candidate 2: o& operator<<(o&, const Domain&)
[with o = std::ofstream]
make: *** [main.o] Error 1
Thank you all!
a²
It seems to be trivial to me, but not for the compiler. I'm using g++
4.2 on an Ubuntu Linux system:
// main()
....
std::ofstream fout;
fout.open("hell o.out");
fout<<setfill('-')<<setw(20)<<"-"<<setfill( ' ')<<endl;
fout<<"hello "; // this is line 139
....
main.cxx:89: instantiated from here
main.cxx:139: error: ISO C++ says that these are ambiguous, even
though the worst conversion for the first is better than the worst
conversion for the second:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/
ostream.tcc:735 : note: candidate 1: std::basic_ostr eam<char, _Traits>&
std::operator<< (std::basic_ost ream<char, _Traits>&, const char*) [with
_Traits = std::char_trait s<char>]
Domain.h:507: note: candidate 2: o& operator<<(o&, const Domain&)
[with o = std::ofstream]
make: *** [main.o] Error 1
Thank you all!
a²
Comment