c++基础不好,谁帮我改改

#include<iostream>
using namespace std;
class Array
{
private:
int *a; int l;
public:
Array()
{
a=NULL;
l=0;
}
Array(int x)
{
int c=0;
a=new int[x];
while (c<x)
{
cin>>a[c];
cin.get();
c++;
}
l=x;
}
~Array()
{
delete []a;
}
void datain(int f)
{
a[l-1]=f;
}
friend int big(Array& s,Array& t)
{
if (s.l>=t.l)
return s.l;
else
return t.l;
}
void operator=(Array &p)
{
l=p.l;
a=new int[l];
for (int j=0;j<l;j++)
a[j]=p.a[j];
}

 Array(Array &p)
 {
    l=p.l;
    a=new int[l];
    for (int j=0;j<l;j++)
         a[j]=p.a[j];
 }

 friend Array operator+(Array& s,Array& t)
 {
    Array r;
    int BIG=big(s,t);
    r.l=BIG;
    r.a=new int[l];
    for (int i=0;i<BIG;i++)
       r.a[i]=s.a[i]+t.a[i];
    return r;
 }
 int average()
 {
    int all=0,i;
    for (i=0;i<l;i++)
        all+=a[i];
    return all/l;
 }
 void show()
 {
    for (int i=0;i<l;i++)
        cout<<a[i]<<" ";
 }

};
int main()
{
Array A1(3);
A1.show();
cout<<endl;
A1.datain(6);
A1.show();
cout<<endl;
cout<<A1.average()<<endl;
Array B(3);
Array C;
C=A1+B;
C.show();
return 0;
}图片

#include<iostream>
using namespace std;
class Array
{
private:
int *a; int l;
public:
Array()
{
a=NULL;
l=0;
}
Array(int x)
{
int c=0;
a=new int[x];
while (c<x)
{
cin>>a[c];
cin.get();
c++;
}
l=x;
}
~Array()
{
delete []a;
}
void datain(int f)
{
a[l-1]=f;
}
friend int big(Array& s,Array& t)
{
if (s.l>=t.l)
return s.l;
else
return t.l;
}
Array& operator=(const Array &p)
{
l=p.l;
a=new int[l];
for (int j=0;j<l;j++)
a[j]=p.a[j];
return *this;
}

 Array(Array &p)
 {
    l=p.l;
    a=new int[l];
    for (int j=0;j<l;j++)
         a[j]=p.a[j];
 }

 friend Array operator+(Array& s,Array& t)
 {
    Array r;
    int BIG=big(s,t);
    r.l=BIG;
    r.a=new int[BIG];
    for (int i=0;i<BIG;i++)
       r.a[i]=s.a[i]+t.a[i];
    return r;
 }
 int average()
 {
    int all=0,i;
    for (i=0;i<l;i++)
        all+=a[i];
    return all/l;
 }
 void show()
 {
    for (int i=0;i<l;i++)
        cout<<a[i]<<" ";
 }

};
int main()
{
Array A1(3);
A1.show();
cout<<endl;
A1.datain(6);
A1.show();
cout<<endl;
cout<<A1.average()<<endl;
Array B(3);
Array C;
C=A1+B;
C.show();
return 0;
}

你的main函数里面有C=A+B这种语句,其中A,B均为Array类的实例。所以你要重载运算符+,也就是实现下面的函数
Array operator+(Array &a, Array &b)

手机也能编译吗?哪个软件啊?