내 VS 2017에 문제가 있습니다. class.cpp 파일에서 메서드의 본문 (예 : 곱하기 곱하기)을 변경할 때마다 주 함수에서 명령을 다시 작성해야합니다. I.E. 내가 a = b * c 인 경우; 나는 "test.cpp"에있는 메인을 삭제하고 덧셈 기호 int를 다시 덧붙여서 컴파일해야한다. 그렇지 않으면 VS가 내 메서드에서 변경 내용을 포함하지 않으며 메서드 구현에서 전혀 변경이 없었기 때문에 동작합니다.VS 2017 C++ 컴파일 문제
이 질문 본문은 Google의 품질 기준을 충족하지 못합니다. 이미 시도한 내용을 포함하여 문제를 완벽하게 설명하고 올바른 문법을 사용하여 작성했는지 확인하십시오.
미리 감사드립니다. (
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;}
을 내가 (프로젝트 또는 어디서나) 여기에서는 모든 변경 후 좀 바보 성명에서 편지 (INT 주 삭제 수행해야합니다
편집 이 해결하기 위해 노력 코드 메신저입니다)) 다시 VS를 class.cpp 파일에 내 변경 내용을 포함 할 수 있도록 다시 추가하십시오.
[둘러보기] (https://stackoverflow.com/tour)를 읽고 [도움말] 페이지 (https://stackoverflow.com/help)를 읽고 관련 코드를 표시하십시오. 에 오신 것을 환영합니다. – Ron
스택 오버플로에 오신 것을 환영합니다. [좋은 질문을하는 방법] (https://stackoverflow.com/help/how-to-ask)을 검토하십시오. 귀하의 질문에는 * 특정 * 코딩 관련 문제에 대한 명확한 개요, 이미 시도한 내용 및 관련 코드가 [Minimal, Complete, Verifiable example] (https://stackoverflow.com/help)에 포함되어야합니다./mcve), 우리는 도울 수있는 충분한 정보를 가지고 있습니다. – FluffyKitten
템플리트가 cpp에 구현되어 있지 않습니다. –