本人在头文件中放了个函数,另外在源文件中编写了函数的实现方法,但是在主函数中进行调用该函数就提示了error LINK2019的问题,问一下这要怎么解决,在网络上搜要用lib也没有弄好。

sum.h文件

sum.h文件
#ifndef SUM_H #define SUM_H int sum(int a,int b); #endif
sum.cpp文件
#include "sum.h"
int sum(int a,int b )
{
return a+b;
}
win32主函数
#include "stdafx.h"
#include "sum.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a,b;
a=3;
b=5;
int c=sum(a,b);
cout<<c<<endl;
int i;
cin>>i;
return 0;
}
解决方案
80
换个名字就行了,可能和系统库里的sum函数重名了。
例如你改成mysum
例如你改成mysum