Hey, right now I am working on implementing a matrix class for an assignment.
I am using vectors in order to implement it and am having some trouble with adding matrices together.
In my private I have defined:
int nRows, nCols;
vector<int> data;
Here is my code for the operator+;
matrix<T> operator+(const matrix<T> & other) const {
int other_rows = other.rows();
int other_cols = other.cols();
data.resize(other_rows*other_cols);
vector<int> other_data ((other_rows*other_cols)); //needs to take in data
for (int j=0;j<nCols;j++) {
for (int i=0;i<nRows;i++) {
data.push_back(data.at(i) + other_data.at(i));
}
}
return *this;
}
Right now I am getting an error that there is no matching function for call... on my lines with:
- data.resize(...)
- vector<int> other_data
- in my nested for loop, data.push_back(...)