title: Templates, no matching function for call to error
body: <p>I've made a code which works just fine but one line. It causes me problems. On the line where it says <code>k = Money&lt;double&gt;().increment (k,m); // this should've printed 6.25</code> it just doesn't work. When you comment it out and run the code... everything works just fine. What's wrong and how can I fix it?</p>
  
  <p>Thank you for your help.</p>
  
  <p>The error in the console says:</p>
  
  <blockquote>
    <p>main.cpp:59:36: error: 'Money::increment(Money&amp;, Money&amp;)' no matching function for call to error 
    main.cpp:59:36: info: candidate is:<br>
    main.cpp:41:3: info: T Money::increment(T, T) [with T = double]<br>
    main.cpp:41:3: info:   no known conversion for argument 1 from 'Money' to 'double'</p>
  </blockquote>
  
  <p>And well... candidate is empty too.
  As I said without that line everything works just perfect.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  template &lt;class T&gt;
  class Money {
    private:
      T dollar, cent;
    public:
      Money(T a, T b){
          dollar = a;
          cent = b;
      }
  
    Money(){
      dollar = 0;
      cent = 1;
    }
  
    Money&amp; operator +=(const Money&amp; v){
      dollar += v.dollar;
      cent += v.cent;
      return (*this);
    }
  
    Money operator +(const Money&amp; v) const{
      Money temp(*this);
      temp += v;
      return temp;
    }
  
    Money&amp; operator =(const Money&amp; v){
      dollar = v.dollar;
      cent = v.cent;
      return (*this);
    }
  
    T increment(T value, T amount);
  };
  
  template &lt;class T&gt;
  T Money&lt;T&gt;::increment(T value, T amount)
  {
    T result = 0;
    result += value + amount;
    cout &lt;&lt; result &lt;&lt; " $" &lt;&lt; endl;
    return result;
  }
  
  int main()
  {
    int a = 2;
    double b = 3.45;
  
    Money&lt;double&gt; k(3,75);
    Money&lt;double&gt; m(2,50);
  
    a = Money&lt;double&gt;().increment (a,5); // this prints 7
    b = Money&lt;double&gt;().increment (b,4.5); // this prints 7.95
    k = Money&lt;double&gt;().increment (k,m); // this should've printed 6.25
    return 0;
  }
  </code></pre>