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

帮忙解决问题

晓宁 发布于 2011-10-17 21:26, 484 次点击
#include<iostream>
using namespace std;

class Max
{
public:
    float maxnum(float,float);
    float maxnum(int,int);
};

float Max::maxnum(float a,float b)
{
    if(a>b)
        return a;
    else
        return b;
}

float Max::maxnum(int c,int d)
{
    if(c>d)
        return c;
    else
        return d;
}

void main()
{
    Max m;
    float x,y;
    int p,q;
    cout<<"Enter two float data type values:";
    cin<<x<<y;
    cout<<"Enter two integer data type values:";
    cin<<p<<q;
    cout<<"\nMaximum of 2 float values:"<<m.maxnum(x,y);
    cout<<"\nMaximum of 2 integer values:"<<m.maxnum(p,q);
}
1 回复
#2
gincms2011-10-27 09:35
cin<<x<<y;
注意细节
应该改为cin>>x>>y;
还有就是 using namespace std;
分号应该是英文的
1