小弟刚刚学习C++,比较菜,以前一直用Gcc写,现在老师强制要求用VC写
我的编译环境是VC++6.0,随便写了一个程序,想试试,结果可以编译,但是无法链接
在Gcc里是可以链接的,小弟不明白,发上来请高手指点指点,小弟无比感激了
#include <iostream>
using namespace std;
int max(int a,int b);
long max(long a,int b);
double max(double a,double b);
int main()
{
int x1,y1;
long x2,y2;
double x3,y3;
cout<<"x1="<<endl;
cin>>x1;
cout<<"y1="<<endl;
cin>>y1;
cout<<"max="<<max(x1,y1)<<endl;
cout<<"x2="<<endl;
cin>>x2;
cout<<"y2="<<endl;
cin>>y2;
cout<<"max="<<max(x2,y2)<<endl;
cout<<"x3="<<endl;
cin>>x3;
cout<<"y3="<<endl;
cin>>y3;
cout<<"max="<<max(x3,x3)<<endl;
return 0;
}
int max(int a,int b)
{
return(a>b?a:b);
}
long max(long a,long b)
{
return(a>b?a:b);
}
double max(double a,double b)
{
return(a>b?a:b);
}
VC提示的错误:
Linking...
1.obj : error LNK2001: unresolved external symbol "long __cdecl max(long,int)" (?max@@YAJJH@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.