title: addition of 2x2 matrices with operator overloading
body: <p>I have the following code.
  The code works fine without the operator + part.
  It gives me </p>
  
  <blockquote>
    <p>error: no match for ‘operator=’ in ‘final[i][j] = (((matrix*)this)->matrix::mat[i][j] + matr->matrix::mat[i][j])’</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>error: no match for ‘operator&lt;&lt;’ in ‘std::cout &lt;&lt; final[i][j]</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  
  class matrix {
  
  private :
  
  int i,j;
  double mat[2][2];
  
  
  public :
  matrix () {
  }
  
  void getdata();
  double determinant();
  matrix operator + (matrix &amp;);
  
  };
  
  //getdata
  void matrix :: getdata() {
  cout &lt;&lt;"Please provide a 2x2 matrix :"&lt;&lt;endl;
  
      for (int i=0;i&lt;2;i++) {
          for (int j=0;j&lt;2;j++) {
  cout &lt;&lt;"Give the elements of the matrix : "&lt;&lt;endl;
  cin &gt;&gt; mat[i][j];
          }
          }
  }
  
  //compute determinant
  double matrix :: determinant () {
  
  double det;
  
  det = mat[0][0]*mat[1][1] -mat[0][1]*mat[1][0];
  
  
  cout &lt;&lt;"The determinant of the matrix is :"&lt;&lt;det&lt;&lt;endl;
  
  
  }
  
  //compute addition
  matrix matrix ::operator +(matrix &amp;matr) {
  matrix final[2][2];
  for (int i=0;i&lt;2;i++) {
      for (int j=0;j&lt;2;j++) {
  final[i][j]=mat[i][j]+matr.mat[i][j];
      }
  }
  cout &lt;&lt;"The addition of the two matrices is :"&lt;&lt;endl;
  
  for (int i=0;i&lt;2;i++) {
      for (int j=0;j&lt;2;j++){
  cout &lt;&lt; final[i][j];
      }
  cout &lt;&lt;endl;
  }
  
  }
  
  
  int  main()
  {
     matrix pinakas1,pinakas2;
     pinakas1.getdata();
     pinakas2.getdata();
     pinakas1.determinant();
     pinakas2.determinant();
     pinakas1+pinakas2;
  
  
      return 0;
  }
  </code></pre>