title: C++ Matrix Class
body: <p>In C, if I wanted to create a matrix struct, I would use:</p>
  
  <pre><code>struct matrix {
    int col, row;
    double data[1]; // I want the matrix entries stored
                    // right after this struct
  }
  </code></pre>
  
  <p>Then I can allocate it with</p>
  
  <pre><code>matrix* allocate_matrix(int row, int col) {
    matrix* m = malloc(sizeof(matrix) + sizeof(double) * (row * col - 1));
    m-&gt;row = row; m-&gt;col = col;
    return m;
  }
  </code></pre>
  
  <p>Now do I do the equiv in C++?</p>
  
  <p>EDIT:</p>
  
  <p>I want to know the cannonical way to implement a matrix class in C++.</p>