title: Error: no matching function for call to 'A::A(A)'
body: <p>I have coded a very basic class</p>
  
  <pre><code>class A
  {
   int n;
   public:
   A(int&amp; val){val=n;}
   A(const int&amp; val=0){n=val;}
   A(A&amp; val){n=val.n;}//work without this constructor
  };
  
  int main()
  {
   A a=3;//want to call A::A(const int&amp;)
   return 0;
  }
  </code></pre>
  
  <p>I don't want to create a constructor with a copy from an instance of <code>A</code> (for a future use)
  What's wrong with this simple code?</p>
  
  <p>Error message :</p>
  
  <pre><code>...\main.cpp||In function 'int main()':|
  ...\main.cpp|16|error: no matching function for call to 'A::A(A)'|
  ...\main.cpp|16|note: candidates are:|
  ...\main.cpp|11|note: A::A(A&amp;)|
  ...\main.cpp|11|note:   no known conversion for argument 1 from 'A' to 'A&amp;'|
  ...\main.cpp|10|note: A::A(const int&amp;)|
  ...\main.cpp|10|note:   no known conversion for argument 1 from 'A' to 'const int&amp;'|
  ...\main.cpp|9|note: A::A(int&amp;)|
  ...\main.cpp|9|note:   no known conversion for argument 1 from 'A' to 'int&amp;'|
  ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
  </code></pre>
  
  <p>It seems <code>3</code> is considered as an instance of <code>A</code>?</p>
  
  <p>If I add <code>A(const A&amp; val){n=val.n;}</code>
  the constructor <code>A(const int&amp;)</code> is chosen.</p>
  
  <p>What can I do to compile successfully without <code>A(const A&amp; val)</code>?</p>