(初学者)我的main.cpp在编译时给我带来了麻烦,这就是我所拥有的:
#include <iostream>
#include <fstream>
#include "Test.h"
int main(){
bool add, sub, transp, mult, multScal;
//Checks each operation at once, some should fail each time depending on contents of C.txt
add=TestAdd();
sub=TestSubtr();
transp=TestTranspose();
mult=TestMultMatrices();
multScal=TestMultByScalar();
cout <<"Add success: " <<add <<'\n' <<"Subtract success: " <<sub <<'\n'
<<"Transpose success: " <<transp <<'\n' <<"Multiplying 2 matrices success: "
<<mult <<'\n' <<"Multiplying by Scalar success: " <<multScal <<"\nThanks for playing!";
}
其中TestAdd()、TestSubtr()等都可以在Test.h中找到。不过,我得到了一个错误,说它们对于 main.cpp 是未定义的。关于为什么的任何线索?
编辑:这是我的Test.h:
#include <iostream>
#include "Matrix.h"
class Test{
public:
bool TestAdd();
bool TestSubtr();
bool TestTranspose();
bool TestMultMatrices();
bool TestMultByScalar();
private:
Matrix loadMatrix(std::string filename);
bool compare(Matrix A, Matrix B);
};