c++里怎么会出现term does not evaluate to a function?

来源:百度知道 编辑:UC知道 时间:2024/06/03 16:00:38
我是一个c++初学者,我写了下面的代码,然后运行时怎么会出现error C2064: term does not evaluate to a function?下面是我写的,到底是哪里错了?那是什么意思?

#include "stdafx.h"
#include<iostream.h>

int main(int argc, char* argv[])
{ int a;
int b;
int max;
cout<<"请输入a"<<endl;
cin>>a;
cout<<"请输入b"<<endl;
cin>>b;
int k;
k=max(a,b);
cout<<k<<endl;
return 0;
}

int max(int a,int b)
{
int m;
if (a>b)
m=a;
else
m=b;
return m;
}

//#include<iostream.h>
#include <iostream>
using namespace std;
int max(int, int);//添加这行 ,声明下面将有这个函数
int main(int argc, char* argv[])
{ int a;
int b;
//int max;这句是错误的,max应该是个函数名,不是变量
cout<<"请输入a"<<endl;
cin>>a;
cout<<"请输入b"<<endl;
cin>>b;
int k;
k=max(a,b);
cout<<k<<endl;
system("pause");//暂停,观察结果
return 0;
}

int max(int a,int b)
{
int m;
if (a>b)
m=a;
else
m=b;
return m;
}

因为缺少stdafx.h文件