title: Why is copy constructor not allowed pass by value?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2685854/why-should-the-copy-constructor-accept-its-parameter-by-reference-in-c">Why should the copy constructor accept its parameter by reference in C++?</a><br>
    <a href="https://stackoverflow.com/questions/4391350/can-a-object-be-passed-as-value-to-the-copy-constructor">Can a object be passed as value to the copy constructor</a>  </p>
  </blockquote>
  
  
  
  <p>Consider this piece of code:</p>
  
  <pre><code>class complex{
          private:
                  double re, im;
          public:
                  complex(double _re, double _im):re(_re),im(_im){}
                  complex(complex c):re(c.re),im(c.im){}
  };
  </code></pre>
  
  <p>When compiled, I got an error message: <code>invalid constructor; you probably meant ‘complex (const complex&amp;)’</code></p>
  
  <p>In the book <code>C++ Programming Language</code>, it is written that:</p>
  
  <blockquote>
    <p>The copy constructor defines what copying means – including what
    copying an argument means – so writing</p>
    
    <p>complex : complex(complex c) :re(c.re) , im(c.im) { } // error</p>
    
    <p>is an error because any call would have involved an infinite recursion.</p>
  </blockquote>
  
  <p>Why does this cause infinite recursion? It doesn't make sense.</p>