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

编译器归错于返回值,但是这种函数木有啊,为什么,亲,谢谢

ice寂地 发布于 2014-04-04 20:47, 357 次点击
#include<iostream>
using namespace std;
class Arry
{
    public:
        int input();
        int sum();
        int ave();
        int max();
        ~Arry();
    private:
        int a[100],p;
};
 Arry::input()
{
    int i=0,p,a[100];
    cout<<"输入要处理数的个数";
    cin>>p;
    cout<<"输入p个数";
    for(;i<p;i++)
        cin>>a[i];
}
 Arry::sum()
 {
    int sum=0,j=0;
    for(;j<p;j++)
        sum+=a[j];
    cout<<sum;
}
 Arry::ave()
{
    int g;
    g=sum();
    cout<<(double)g/p;
}
 Arry::max()
{
    int s,f=1;
    s=a[0];
    for(;f<p;f++)
    if(s<a[f])
      s=a[f];
}
 Arry::~Arry()
{
    cout<<"no";
}
int main()
{
    Arry m;
    m.input();
    m.max();
    m.sum();
    m.ave();
    return 0;
}
0 回复
1