title: Working of parameterized constructor in C++ when variables are initailized vs uninitialized
body: <p>Below C++ code works.</p>
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  class Complex{
  private:
      int real, imag;
  public:
      Complex(int r=0, int i=0){
          real = r;      imag = i;
      }
  };
  
  
  int main()
  {
      Complex c1(10, 5), c2(2, 4);
      Complex c3;
  }
  </code></pre>
  <p>When the parameterized constructor's variables <code>r</code> and <code>i</code> are uninitialized(eg: <code>Complex(int r, int i)</code>), the compiler throws up the error</p>
  <p><strong>main.cpp:19:13: error: no matching function for call to ‘Complex::Complex()’
  19 |     Complex c3;
  |             ^~
  main.cpp:10:5: note: candidate: ‘Complex::Complex(int, int)’
  10 |     Complex(int r, int i){
  |     ^~~~~~~.</strong></p>
  <p>I understood this to be an issue with the statement <code>Complex c3;</code>. Pardon me for being naive, but it's unclear why it works this way in the initial code snippet itself. Hope someone can clarify this.</p>