title: Ambiguous Overloaded Constructor: C++
body: <p>I'm finishing up an assignment that has to do with matrix multiplication. We were given some skeleton files which I have filled; however I am dealing with an ambiguous constructor error, and the constructor must stay the same for the way it is graded:</p>
  
  <p>test.cpp:6:7 error: call of overloaded 'Mat4()' is ambiguous</p>
  
  <p>In my test code I want</p>
  
  <pre><code>Mat4 I; // to result in a call to SetIdentity() via the default constructor
  I.Print( "I = " ); // should print the Identity Matrix for a 4x4
  </code></pre>
  
  <p>The relevant Mat4.h code:</p>
  
  <pre><code>class Mat4{
  protected:
      float   m[4][4];
  
  public:
      // ** 3A: **
  Mat4( );
  Mat4( float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0, float=0 );
  </code></pre>
  
  <p>And my Mat4.cpp code:</p>
  
  <pre><code>Mat4::Mat4( ){
  SetIdentity( );
  }
  
  Mat4::Mat4( float a, float b, float c, float d, float e, float f, float g, float h,   float i, float j, float k, float l, float n, float o, float p, float q){
  m[0][0] = a;
  m[0][1] = b;
  m[0][2] = c;
  m[0][3] = d;
  m[1][0] = e;
  m[1][1] = f;
  m[1][2] = g;
  m[1][3] = h;
  m[2][0] = i;
  m[2][1] = j;
  m[2][2] = k;
  m[2][3] = l;
  m[3][0] = n;
  m[3][1] = o;
  m[3][2] = p;
  m[3][3] = q;
  }
  </code></pre>
  
  <p>An example use of the non-default constructor:</p>
  
  <pre><code>Mat4
  Mat4::operator*( Mat4&amp; that ){
  // "this" is a pointer to this class's mat4  (this-&gt;name)
  // "that" is a reference to the other matrix (that.name)
  
  Mat4 result(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  int i, j, k;
  for(i = 0; i &lt; 4; i++){
      for(j = 0; j &lt; 4; j++){
          for(k = 0; k &lt; 4; k++){
              result.m[i][j] += (float)(this-&gt;m[i][k]*that.m[k][j]);
          }
      }
  }
  return result;
  }
  </code></pre>
  
  <p>Thank you for your help!</p>