conversion precedence in c++
<p>I have the following code:</p>

<pre><code>Some functions:

A::A(int i_a) {cout&lt;&lt;"int Ctor\n";}          //conversion constructor

void h(double d) {cout&lt;&lt;"double param\n";}   //f1
void h(A a) {cout&lt;&lt;"A param\n";}             //f2
</code></pre>

<p>In the main function:</p>

<pre><code>h(1);
</code></pre>

<p>The function that h(1) calls is f1. </p>

<p>My question is why does it choose to call that. 1 is an int and therefore requires 
implicit conversion to double. It could just as easily convert the int into an A using the 
conversion constructor defined above. Why don't I get an error? What are the 
precedence rules with casting?</p>

<p><hr /></p>

<p>N.b. I've posted above the code that I think will be necessary to answer the question, 
but below I'm posting the entire code:</p>

<pre><code> #include &lt;iostream&gt;
 using namespace std;
 class B;
 class A {
 public:
 explicit A(const B&amp;) {cout&lt;&lt;"Ctor through B\n";}
 A() {cout&lt;&lt;"Default Ctor\n";}
 A(int i_a) {cout&lt;&lt;"int Ctor\n";}
 operator int() {cout&lt;&lt;"A =&gt; int\n"; return 2;}
 };
 class B {
 public:
 operator A() const {cout&lt;&lt;"B =&gt; A\n"; A a; return a;}
 };
 void h(double d) {cout&lt;&lt;"double param\n";}
 void h(A a) {cout&lt;&lt;"A param\n";}
 void f(const A&amp; a)
 {
 cout&lt;&lt;"f function\n";
 //Without the const it will never try to convert
 }
 void main()
 {
 B b;
 cout &lt;&lt;"-----------------\n";
 f(b);
 cout &lt;&lt;"-----------------\n";
 h(1);
 }
</code></pre>
