C++进来看看

来源:百度知道 编辑:UC知道 时间:2024/06/02 06:01:11
#include <iostream>
#define MAX(a,b) (a>b)?a:b //表条件
int main()
{
int x, y ,max;
cout <<"please input two numbers: \n";
cin >>x;
cin >> y;
F:\VB\MSDev98\MyProjects\work\实参代替形参.cpp(6) : error C2065: 'cout' : undeclared identifier
F:\VB\MSDev98\MyProjects\work\实参代替形参.cpp(6) : error C2297: '<<' : illegal, right operand has type 'char [28]'
F:\VB\MSDev98\MyProjects\work\实参代替形参.cpp(7) : error C2065: 'cin' : undeclared identifier
F:\VB\MSDev98\MyProjects\work\实参代替形参.cpp(7) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
F:\VB\MSDev98\MyProjects\work\实参代替形参.cpp(8) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
F:\VB\MSDev98\MyProjects

首先前面加一段:
using namespace std;

然后有些小错:
#include <iostream>
using namespace std;
#define MAX(a,b) (a>b)?a:b //表条件
int main()
{
int x, y ,max;
cout <<"please input two numbers: \n";
cin >>x;
cin >> y;
max=MAX(x,y);
cout<<"the max=" <<max<<endl;
return 0;
}

而且宏定义得函数会出现很多问题,也达不到你文件名说的实参代替形参的功能,建议使用内联函数

在int main前面加一句
using namespace std;

#include <iostream> 改成#include <iostream.h>