I have problem with my VS 2017. Everytime i change the body of my method (e.g. multiplication of matirces) in the class.cpp file i have to rewrite instruction in main function. I.E. if I have an a = b * c; statement i must delete and add again multiplication symbol int the main in "test.cpp" and then compile. Otherwise VS will not include the change in my method and will act as there was no change at all in the method implementation.
Thanks in advance.
EDIT This is the code im trying to fix:
template<typename T>
Mx::Matrix<T>::Matrix(unsigned rows, unsigned cols, T const & init_val)
{
_matrix.resize(rows);
for (unsigned i = 0; i < _matrix.size(); i++)
_matrix[i].resize(cols, init_val);
_rows = rows;
_cols = cols;
}
template<typename T>
Mx::Matrix<T>::Matrix(Matrix<T> const & mx)
{
_matrix = mx._matrix;
_rows = mx.GetRows();
_cols = mx.GetCols();
}
template<typename T>
Mx::Matrix<T> & Mx::Matrix<T>::operator=(Matrix<T> const & mx)
{
if (this == &mx)
return *this;
unsigned new_rows = mx.GetRows();
unsigned new_cols = mx.GetCols();
_matrix.resize(new_rows);
for (unsigned i = 0; i < _matrix.size(); i++)
_matrix[i].resize(new_cols);
for (unsigned i = 0; i < new_rows; i++) {
for (unsigned j = 0; j < new_cols; j++) {
_matrix[i][j] = mx(i, j); // musisz przeciazyc operator()()
}
}
_cols = new_cols;
_rows = new_rows;
return *this;
}
template<typename T>
Mx::Matrix<T> Mx::Matrix<T>::operator+(Matrix<T> const & mx) const
{
Mx::Matrix<T> temp(mx); // ALBO Mx::Matrix<T> temp(_rows, _cols, 0.0)
for (unsigned i = 0; i < this->GetRows(); i++) {
for (unsigned j = 0; j < this->GetCols(); j++) {
temp(i, j) = (*this)(i, j) + mx(i, j); // ALBO this->_matrix[i][j]
}
}
return temp;
}
template<typename T>
Mx::Matrix<T>& Mx::Matrix<T>::operator+=(Matrix<T> const & mx)
{
return *this = *this + mx;
}
template<typename T>
Mx::Matrix<T> Mx::Matrix<T>::operator-(Matrix<T> const & mx) const
{
Mx::Matrix<T> temp(mx); // ALBO Mx::Matrix<T> temp(_rows, _cols, 0.0)
for (unsigned i = 0; i < this->GetRows(); i++) {
for (unsigned j = 0; j < this->GetRows(); j++) {
temp(i, j) = (*this)(i, j) - mx(i, j); // ALBO this->_matrix[i][j]
}
}
return temp;
}
template<typename T>
Mx::Matrix<T>& Mx::Matrix<T>::operator-=(Matrix<T> const & mx)
{
return *this = *this - mx;
}
template<typename T>
Mx::Matrix<T> Mx::Matrix<T>::operator*(Matrix<T> const & mx)
{
unsigned rows = mx.GetRows();
unsigned cols = this->GetRows();
Mx::Matrix<T> temp(rows, cols, 0.0);
for (unsigned i = 0; i < rows; i++) {
for (unsigned j = 0; j < cols; j++) {
for (unsigned k = 0; k < rows; k++) {
temp(i, j) += (*this)(i, k) * mx(k, j);
}
}
}
return temp;}
and after every change I make here (or anywhere in the project) I must do some silly delete a letter from statement (int main()) and add it again so VS could include my changes in the class.cpp file...