Home

On Sep 26, 2:41 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
> aaragon wrote:
> > 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("hello.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_ostream<char, _Traits>&
> > std::operator<<(std::basic_ostream<char, _Traits>&, const char*) [with
> > _Traits = std::char_traits<char>]
> > Domain.h:507: note: candidate 2: o& operator<<(o&, const Domain&)
> > [with o = std::ofstream]
> > make: *** [main.o] Error 1
>
> I don't see any "Domain.h" or types called 'Domain' in your code.
>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask

Well, I overloaded operator<< to produce the output of a class that I
designed. But shouldn't the compiler deduct this from the type being
passed to operator<<???? Why is it the call ambiguous????

previous
next

Re: curses library
Re: sorteddict [was a PEP proposal, but isn't anymore!]
Re: Quick shallow-copy idiom
Re: IDE for Python
Re: exit error
Dzieci Niczyje
Kidprotect
Rodzic Po Ludzku
Fundacja Sloneczko
Fundacja Hobbit