* REH:
> Can some tell me why the chooses the constructor in class B over operator B
> in class A? Is this not ambiguous?
>
> Thanks.
>
>
> #include <iostream>
>
> using namespace std;
>
> struct A;
>
> struct B {
> B() {}
> B(const A&) {} // this is choosen
> };
>
> struct A {
> A() {}
> operator B() const {return B();} // this is not
> };
>
> int main()
> {
> A a;
> B b;
>
> b = a; // ambiguous?
> }
Comeau online compilation:
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 18: error: more than one user-defined conversion from "A"
to
"const B" applies:
function "A:

perator B() const"
function "B::B(const A &)"
b = a; // ambiguous?
^
1 error detected in the compilation of "ComeauTest.c".
In strict mode, with -tused, Compile failed
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?