Note that there are some explanatory texts on larger screens.

plurals
  1. POError: expected constructor, destructor, or type conversion before ‘::’ token
    text
    copied!<p>I am getting an error when trying to compile my class.</p> <p>The error:</p> <p><strong>Matrix.cpp:13: error: expected constructor, destructor, or type conversion before ‘::’ token</strong></p> <p><strong>Matrix.h</strong></p> <pre><code>#ifndef _MATRIX_H #define _MATRIX_H template &lt;typename T&gt; class Matrix { public: Matrix(); ~Matrix(); void set_dim(int, int); // Set dimensions of matrix and initializes array unsigned int get_rows(); // Get number of rows unsigned int get_cols(); // Get number of columns void set_row(T*, int); // Set a specific row with array of type T void set_elem(T*, int, int);// Set a specific index in the matrix with value T bool is_square(); // Test to see if matrix is square Matrix::Matrix add(Matrix); // Add one matrix to another and return new matrix Matrix::Matrix mult(Matrix);// Multiply two matrices and return new matrix Matrix::Matrix scalar(int); // Multiply entire matrix by number and return new matrix private: unsigned int _rows; // Number of rows unsigned int _cols; // Number of columns T** _matrix; // Actual matrix data }; #endif /* _MATRIX_H */ </code></pre> <p><strong>Matrix.cpp</strong></p> <pre><code>#include "Matrix.h" template &lt;typename T&gt; Matrix&lt;T&gt;::Matrix() { } Matrix::~Matrix() { // Line 13 } </code></pre> <p><strong>main.cpp</strong></p> <pre><code>#include &lt;stdlib.h&gt; #include &lt;cstring&gt; #include "Matrix.h" int main(int argc, char** argv) { Matrix&lt;int&gt; m = new Matrix&lt;int&gt;(); return (EXIT_SUCCESS); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload