Matrix.h:
#ifndef MATRIX_H_INCLUDED
#define MATRIX_H_INCLUDED
#include <iostream>
using namespace std;
template <typename T>
class Matrix {
int m;
int n;
T **data;
public:
void newData(int, int);
}
#endif
Matrix.cpp:
#include "Matrix.h"
template <typename T> // here is the error
void Matrix<T>::newData(int m, int n) {
int i;
int j;
this->m = 0;
this->n = 0;
this->data = NULL;
if (m <= 0 || n <= 0)
return;
this->data = new T*[m];
for (i = 0; i < m; i++)
{
this->data[i] = new T[n];
for (j = 0; j < n; j++)
this->data[i][j] = 0;
}
this->m = m;
this->n = n;
}
编译器想告诉我什么?
如何修复这些错误?
答案 0 :(得分:1)
你在课程结束时忘记了;
。
template <typename T>
class Matrix {
int m;
int n;
T **data;
public:
void newData(int, int);
}; // <------------------------- Here