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);

}

 

结果总是报错:

one or more multiply defined symbols found.

 

这是怎么回事那?

[解决方法]

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM