title: Unable to fix a Access Violation reading location error
body: <p>So, I've looked around for an answer for a while, trying to solve this error. I think I know what the problem is, but I still can't find where or how it's happening exactly.</p>
  
  <p>The error is that I'm getting a Access Violation at the location 0xcccccccc. My searching has lead me to that the problem is that I'm trying to delete a pointer that either doesn't exist, which I don't believe, or that I'm deleting a temporary variable. The problem is that I can't figure out which it is. I'm sure that once it's pointed out I'll feel stupid, but I REALLY can't seem to see this.</p>
  
  <p>Pertinent Code down the callstack from the top.</p>
  
  <pre><code>// Minimum Polynomial Function
  matrix matrix::MIN_POLY()
  {
    // Get stuff ready to find the Minimal Polynomial of the matrix
    // Get our I matrix in.
  
    col[0] = MatrixPow( *this, 0); // Goes in here &lt;-
  
  // ... Rest of the function ...
  
  }
  
  
  
  // Matrix Power Function
  matrix matrix::MatrixPow(matrix&amp; A, int pow)
  {
    // Create an identity matrix should the pow == 0
    matrix ret(A.size[0], A.size[1]);
  
    for(int i = 0; i &lt; ret.size[0]; ++i)
    {
      ret.data[i][i] = 1;
    }
  
    for( int i = 0; i &lt; pow; ++i)
    {
      // multiply it by the number of times given, and 0 returns I
      ret = MatrixMult(ret, A);
    }
  
    // Ret.data exists here still and is ready to be moved and deleted.
    return ret; // Seems to call Copy around here for some reason. &lt;------
  }
  
  
  
  // Copy constructor
  matrix::matrix(const matrix&amp; other)
  {
    // Ret.data is gone by here for some reason.
    if(data)
    {
      for(int i = 0; i &lt; size[0]; ++i)
      {
        delete[] data[i]; // Error happens in one of these deletes &lt;-----
      }
    delete[] data;
    }
  // Rest doesn't matter as it stops above
  }
  </code></pre>
  
  <p>And the matrix.h since it was asked for.</p>
  
  <pre><code>#include &lt;complex&gt;
  
  class matrix
  {
  private:
    std::complex&lt;float&gt; **data; // [row][column]
    int size[2]; // 0 is rows/ 1 is columns
  
  public:
    // Default Constructor 
    matrix();
    // Default Destructor
    ~matrix();
    // Default Copy
    matrix(const matrix&amp; other);
    // Premade matrix constructor
    matrix(int row, int col, std::complex&lt;float&gt;** mat);
    // Assignment operator to get stuff done
    matrix&amp; operator=(const matrix&amp; other);
    // Set function for the matrix
    void Set(int row, int col, std::complex&lt;float&gt; dat);
    // Get function for the matrix, inline for ease.
    std::complex&lt;float&gt; Get(int row, int col)
    {return data[row][col];}
    // Get function for the number of rows
    int GetRows()
    {return size[0];}
    // Get function for the number of columns
    int GetCol()
    {return size[1];}
    // Scalar Multiplication
    void ScalarMult(std::complex&lt;float&gt; scalar);
    // Matrix Multiplication
    matrix MatrixMult(const matrix&amp; A, const matrix&amp; B);
    // Matrix Power series
    matrix MatrixPow(matrix&amp; A, int pow);
    // Matrix addition
    matrix MatrixAdd(const matrix&amp; lhs, const matrix&amp; rhs);
    // Row op addition
    void RowOp(int row1, int row2, std::complex&lt;float&gt; val1, std::complex&lt;float&gt; val2);
    // Row op Swap
    void RowSwap(int row1, int row2);
    // RREF function
    void RREF();
    // minimal Polynomial
    matrix MIN_POLY();
  };
  </code></pre>