one or more multiply defined symbols found

在一个c++的.h文件中加入了这段代码:

#include <string>

using namespace std;

std::string escapeStr(const std::string& input)

{

       return std::string(input);

}

结果总是报错:

扫描二维码关注公众号,回复: 993861 查看本文章

one or more multiply defined symbols found.

这是怎么回事那?

[解决方法]

在.h文件中只能放函数的声明,不要放函数体. 函数体要放到.cpp文件中去.

猜你喜欢

转载自www.cnblogs.com/time-is-life/p/9077422.html