请各位帮看看,弹出错误:error LNK2019: 无法解析的外部符号 "int __cdecl sum(i

C++语言 码拜 8年前 (2016-04-17) 755次浏览
本人在头文件中放了个函数,另外在源文件中编写了函数的实现方法,但是在主函数中进行调用该函数就提示了error LINK2019的问题,问一下这要怎么解决,在网络上搜要用lib也没有弄好。
请各位帮看看,弹出错误:error LNK2019: 无法解析的外部符号 "int __cdecl sum(i
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

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明请各位帮看看,弹出错误:error LNK2019: 无法解析的外部符号 "int __cdecl sum(i
喜欢 (0)
[1034331897@qq.com]
分享 (0)