注册 登录
编程论坛 C++教室

简单的自定义语句、、讨教

晴天一阵 发布于 2011-09-04 19:12, 414 次点击
#include<iostream>
typedef float DataType
    DataType Max3(DataType x1,DataType x2)
{
    if(x1>=x2)return x1;
    else return x2;
}
DataType main()
{
    DataType t1=5.1,t2=8.8,max;
    max=Max3(t1,t2);
    cout<<"Max="<<max<<endl;
}
VS2010报错cout,endl未定义,不知道哪里错了。求教!
5 回复
#2
烟雾中的迷茫2011-09-04 21:43
好像是美使用名字空间 而且main一般返回int 而不是float
#3
烟雾中的迷茫2011-09-04 21:47
回复 楼主 晴天一阵
main 一般返回int 而不是float  最后加上 return 0;
#4
pangding2011-09-04 23:06
在 include 下一行加上
using namespace std;
就行了。

或者
把 cout 改成 std::cout
把 endl 改成 std::endl
也可以。
#5
zfdf22332011-09-05 07:41
楼上正解
#6
daniel19862011-09-09 22:51
加上using namespace std;即可
1