title: The popular (c++) "error: no matching function for call to ... ", with a kick though
body: <p>I am working in c++.</p>
  
  <p>my class <code>animation.h</code> is the following:</p>
  
  <pre><code>class Animation
  {
  public:
      Animation(ofVec2f _startLoc, ofVec2f _endLoc, float _speed, float _accel);
      virtual ~Animation();
  };
  </code></pre>
  
  <p>then in <code>sceneMusic.h</code> I have another class that calls <code>animation</code> class.</p>
  
  <pre><code>#include "animation.h"
  class sceneMusic
  {
      public:
          sceneMusic();
          virtual ~sceneMusic();
      private:
          Animation staveMotion;
  };
  </code></pre>
  
  <p>and <code>sceneMusic.cpp</code></p>
  
  <pre><code>sceneMusic::sceneMusic()
  {
      staveImg.loadImage("./sceneMusic/stave_white.png");
  
      staveMotion = Animation(ofVec2f(29, -staveImg.height()), \
                              ofVec2f(29, 249), 1, 0.1);
  }
  </code></pre>
  
  <p>The above gives the following (expected) error:</p>
  
  <pre><code>src/awards/sceneMusic.cpp|3|error: no matching function for call to ‘Animation::Animation()’|
  src/awards/sceneMusic.cpp|5|note: candidates are:|
  src/Animation.h|14|note: Animation::Animation(ofVec2f, ofVec2f, float, float)|
  src/Animation.h|14|note:   candidate expects 4 arguments, 0 provided|
  </code></pre>
  
  <p>I read alot of threads that suggest I should use <code>initializer lists</code> and do in <code>sceneMusic.cpp</code></p>
  
  <pre><code>sceneMusic::sceneMusic()
      :Animation(ofVec2f(29, -staveImg.height()), \
                 ofVec2f(29, 249), 1, 0.1)
  {
      staveImg.loadImage("./sceneMusic/stave_white.png");
  }
  </code></pre>
  
  <p>or something similar.
  The problem is that the <code>height</code> of staveImg will only become available once the constructor will be executed.</p>
  
  <p>Also the class <code>sceneMusic</code> does not inherit class <code>animation</code>, therefore I am not sure how the above would work. If I attempt to run the above I get </p>
  
  <pre><code>src/awards/sceneMusic.cpp|4|error: type ‘Animation’ is not a direct base of ‘sceneMusic’|
  src/awards/sceneMusic.cpp|4|error: ‘((sceneMusic*)this)-&gt;sceneMusic::staveImg.ofImage_&lt;unsigned char&gt;::height’ cannot be used as a function|
  src/awards/sceneMusic.cpp|5|error: no matching function for call to ‘Animation::Animation()’|
  src/awards/sceneMusic.cpp|5|note: candidates are:|
  ...
  </code></pre>
  
  <p>What am I doing wrong ?</p>
  
  <p>thank you for your help</p>