Я получаю сообщение об ошибке при попытке скомпилировать мой класс.
Ошибка:
Matrix.cpp: 13: ошибка: ожидаемый конструктор, деструктор или преобразование типов перед токеном ‘::’
Matrix.h
#ifndef _MATRIX_H
#define _MATRIX_H
template <typename T>
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 */
Matrix.cpp
#include "Matrix.h"
template <typename T>
Matrix<T>::Matrix() {
}
Matrix::~Matrix() { // Line 13
}
main.cpp
#include <stdlib.h>
#include <cstring>
#include "Matrix.h"
int main(int argc, char** argv) {
Matrix<int> m = new Matrix<int>();
return (EXIT_SUCCESS);
}