vs 2017 C 汇编问题
VS 2017 C++ compilation problems
我对我的VS 2017都有问题。每次我更改class.cpp文件中的方法的主体(例如Matirice的乘法)时,我必须在MAIM函数中重写指令。IE。如果我有a = b * c;语句我必须删除并再次添加乘法符号在" test.cpp"中的主体,然后编译。否则,v将不会在我的方法中包括更改,并且会因为方法实施中根本没有更改。
预先感谢。
编辑这是我试图修复的代码:
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 main(int Main())的信,然后添加它,以便VS可以将我的更改包括在class.cpp文件中。..
您共享的代码来自class.cpp文件?正如 @manni66在对问题的评论中提到的那样,它必须全部都在标头文件中,或者至少包含在标头文件中。查看为什么仅在标题文件中实现模板?
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 汇编问题试图使用qobject_cast进行const指针
- 类向量上的C 汇编问题
- 关于Visual Studio 2017中有关ConstexPR表达式的汇编问题
- QT_Screen的汇编问题
- C 汇编器转换问题
- c IPERF3的汇编问题
- vs 2017 C 汇编问题
- C 汇编问题:找不到对象文件
- .cpp中.o文件的调用函数的汇编问题
- C/C++汇编.在处理项目的简单生成文件时遇到问题
- 我的汇编代码有什么问题
- DirectX输入汇编阶段问题
- 关于反汇编输出的问题
- 汇编偏移到c++代码的问题