I have a template class of a dynamic matrix. I want to ask the user for the number of matrices they want to add, and then create the matrix objects within a for loop through storing them in an array.
This is the class constructor:
template <class E>
class Matrix{
public:
//CONSTRUCTOR
Matrix(int m, int n) {
this->m = m;
this->n = n;
matrix = new E*[m];
for(int i=0; i<m; i++) {
matrix[i] = new E[n];
}
}
For that, the array must be of the template class type:
std::cout<<"\nWho many matrices do you want to sum?"; std::cin>>numMxToSum;
Matrix<float> *matricesToSum[numMxToSum];
for(int i=0; i<numMxToSum; i++) {
matricesToSum[i] = Matrix<float> matrixObjToSum(m,n);
}
But when I try to run it, I get: "[Error] expected primary-expression before 'matrixObjToSum'"
How can I store multiple matrix objects inside an array?