title: In constructor, candidate expects 1 argument, 0 provided
body: <p>This is the code:</p>
  
  <pre><code>class cat
  {
      private:
          int height;
      public:
          cat (int inputHeight);
  };
  
  cat::cat (int inputHeight)
  {
      height = inputHeight;
  }
  
  class twoCats
  {
      private:
          cat firstCat;
          cat secondCat;
      public:
          twoCats (cat theFirstCat);
          void addSecondCat (cat theSecondCat);
  };
  
  twoCats::twoCats (cat theFirstCat)
  {
      firstCat = theFirstCat;
  }
  
  void twoCats::addSecondCat (cat theSecondCat)
  {
      secondCat = theSecondCat;
  }
  
  int main() {return 0;}
  </code></pre>
  
  <p>And these are the errors:</p>
  
  <pre><code>main.cpp: In constructor ‘twoCats::twoCats(cat)’:
  main.cpp:24:34: error: no matching function for call to ‘cat::cat()’
  main.cpp:24:34: note: candidates are:
  main.cpp:9:1: note: cat::cat(int)
  main.cpp:9:1: note:   candidate expects 1 argument, 0 provided
  main.cpp:1:7: note: cat::cat(const cat&amp;)
  main.cpp:1:7: note:   candidate expects 1 argument, 0 provided
  main.cpp:24:34: error: no matching function for call to ‘cat::cat()’
  main.cpp:24:34: note: candidates are:
  main.cpp:9:1: note: cat::cat(int)
  main.cpp:9:1: note:   candidate expects 1 argument, 0 provided
  main.cpp:1:7: note: cat::cat(const cat&amp;)
  main.cpp:1:7: note:   candidate expects 1 argument, 0 provided
  </code></pre>
  
  <p>I don't understand the following:</p>
  
  <ol>
  <li>Why does the constructor for <code>twoCats</code> try to call the default constructor for <code>cat</code>? Surely it does not need to construct an instance of <code>cat</code> as when <code>twoCats</code> is initialised it will be passed an already initialised instance of <code>cat</code> which will have been passed the <code>int height</code> argument?</li>
  <li>Why is the same block of error messages shown twice? I called <code>g++ main.cpp</code> on Ubuntu 12.04.</li>
  </ol>