当我尝试编译代码时收到此错误消息:
c ++ -Ofast -march = native -DNDEBUG -std = c ++ 11 -Wc ++ 11-extensions -Wall matvec.o amath483.o Vector.o -o matvec
matvec.o:在函数
0 == false; // true "" == false; // true NaN == false; // false 0 / 0 == false; // false
中readVector(std :: __ cxx11 :: basic_string,std :: allocator>)' clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)makefile:5:目标配方' matvec'失败了:*** [matvec]错误1
我的代码如下:
main': matvec.cpp:(.text+0x209): undefined reference to
答案 0 :(得分:0)
显然,输入类型错误:std::string inputfile
不是std::ifstream
或std::istream
。您需要打开一个输入std::ifstream
文件,其名称存储在inputfile
中,然后将其传递给readVector
。