VC出现error LNK2005 错误应该怎么办??
--------------------Configuration: abc - Win32 Debug--------------------
Linking...
main.obj : error LNK2005: "double __cdecl AVE(double,double,double)" (?AVE@@YANNNN@Z) already defined in abc.obj
Debug/abc.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
abc.exe - 1 error(s), 0 warning(s)
---main.cpp---
#include <iomanip.h>
#include "abc.cpp"
void main()
{
double a,b,c;
double averageValue;
a=2;b=3;c=4;
averageValue=AVE(a,b,c);
cout<<"averageValue:"<<averageValue<<endl;
averageValue=AVE(a,b+1,c+2);
cout<<"averageValue:"<<averageValue<<endl;
}
---abc.cpp---
double AVE(double x,double y,double z)
{
return (x+y+z)/3;
}
在abc.h文件中写函数AVE的声明,然后纯枯握在main.cpp中#include "abc.h"败扰
或者
在工程中排除掉abc.cpp文做庆件