Template Matrix scalar multiplication c++
<p>When I try to compile the following coding, I have get an error saying </p>

<p><strong>Error 1   error LNK2019: unresolved external symbol "class Matrix __cdecl operator*(int const &amp;,class Matrix &amp;)" (??D@YA?AV?$Matrix@H$02$01@@ABHAAV0@@Z) referenced in function _main   C:\Users\pc\Documents\Visual Studio 2013\Projects\Homework4\Homework4\main.obj  Homework4</strong></p>

<p>This error is occurred from the scalar multiplication on matrix and I don't know how to fix it.  Can anyone give me an advice on this?</p>

<pre><code>//Matrix.h
#pragma once
#include &lt;iostream&gt;
#include &lt;vector&gt;
using namespace std;

template&lt;class T, int m, int n&gt;
class Matrix
{
vector&lt;vector&lt;T&gt;&gt; elements;
int nrow;
int ncol;

public:
Matrix();
~Matrix();
void print();
vector&lt;T&gt; row(int);
vector&lt;T&gt; col(int);

friend Matrix&lt;T, m, n&gt; operator+&lt;&gt;(const Matrix&lt;T, m, n&gt;&amp;, const Matrix&lt;T, m, n&gt;&amp;);
friend Matrix&lt;T, m, n&gt; operator-&lt;&gt;(const Matrix&lt;T, m, n&gt;&amp;, const Matrix&lt;T, m, n&gt;&amp;);
friend Matrix&lt;T, m, n&gt; operator*(const T&amp;, Matrix&lt;T, m, n&gt;&amp;);

};

template&lt;class T, int m, int n&gt;
Matrix&lt;T, m, n&gt;::Matrix() : nrow(m), ncol(n)
{
for (int i = 0; i &lt; nrow; i++){
    vector&lt;T&gt; row(ncol, i);
    elements.push_back(row);
}
}

template&lt;class T,int m,int n&gt;
vector&lt;T&gt; Matrix&lt;T, m, n&gt;::row(int i)
{
return elements[i];
}

template&lt;class T, int m, int n&gt;
vector&lt;T&gt; Matrix&lt;T, m, n&gt;::col(int j)
{
vector&lt;T&gt; col;
for (int i = 0; i &lt; ncol; i++)
{
    col.push_back(elements[i][j]);
}
return col;
}

template&lt;class T, int m, int n&gt;
Matrix&lt;T, m, n&gt;::~Matrix(){}

template&lt;class T, int m, int n&gt;
void Matrix&lt;T, m, n&gt;::print()
{
for (int i = 0; i &lt; nrow; i++){
    for (int j = 0; j &lt; ncol; j++)
    {
        cout &lt;&lt; elements[i][j] &lt;&lt; " ";
    }
    cout &lt;&lt; endl;
}
}

template&lt;class T, int m, int n&gt;
Matrix&lt;T, m, n&gt; operator+(const Matrix&lt;T, m, n&gt;&amp; m1, const Matrix&lt;T, m, n&gt;&amp; m2){
Matrix&lt;T, m, n&gt; m3;
int nrow = m1.nrow;
int ncol = m1.ncol;
for (int i = 0; i &lt; nrow; ++i){
    for (int j = 0; j &lt; ncol; ++j){
        m3.elements[i][j] = m1.elements[i][j] + m2.elements[i][j];
    }
}

return m3;
}

template&lt;class T, int m, int n&gt;
Matrix&lt;T, m, n&gt; operator-(const Matrix&lt;T, m, n&gt;&amp; m1, const Matrix&lt;T, m, n&gt;&amp; m2){
Matrix&lt;T, m, n&gt; m3;
int nrow = m1.nrow;
int ncol = m1.ncol;
for (int i = 0; i &lt; nrow; ++i){
    for (int j = 0; j &lt; ncol; ++j){
        m3.elements[i][j] = m1.elements[i][j] - m2.elements[i][j];
    }
}

return m3;
}


template&lt;class T, int m, int n&gt;
Matrix&lt;T, m, n&gt; operator*(const T&amp; c, const Matrix&lt;T, m, n&gt;&amp; m1){
int nrow = m1.nrow;
int ncol = m1.ncol;
Matrix&lt;T, m, n&gt; m2;
for (int i = 0; i &lt; nrow; ++i){
    for (int j = 0; j &lt; ncol; ++j){
        m2.elements[i][j] = c*m1.elements[i][j];
    }
}
return m2;
}

//main.cpp
#include "Matrix.h"
using namespace std;

int main()
{
Matrix&lt;int, 3, 2&gt; a;
Matrix&lt;int, 3, 2&gt; b;
Matrix&lt;int, 3, 2&gt; c;
c = 2*b;

c.print();  
}
</code></pre>

<p>I think the error comes from the friend function (operation *) in the body of the class, but I don't know how to fix it...</p>