在线求助!!!!!!!!!!

tonychoppe tonychoppe 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <iostream.h>
class vector
{
private:
int a[3];
public:
vector & operator =(vector &);
vector(int,int,int);
friend vector & operator +(vector &,vector &);
friend ostream & operator <<(ostream &,vector &);
};

vector::vector(int a,int b,int c):a[0](a),a[1](b),a[3](c){}

vector & vector::operator =(vector & s1)
{
vector s2(0,0,0);
for(int i=0;i<3;i++)
s2.[i]=s1.[i];
return s2;
}

vector & operator +(vector & x,vector & y)
{
vector s(0,0,0);
for(int i=0;i<3;i++)
s.a[i]=x.a[i]+y.a[i];
return s;
}

ostream & operator <<(ostream & output,vector & s)
{

cout<<s.a<<" "<<s.b<<" "<<s.c<<" "<<endl;
return output;
}

void main()
{
vector a(7,8,9),b(6,8,10),c(0,0,0);
cout<<a;
cout<<b;
c=a+b;
cout<<c;
}




总是报错,将类定义的数组改成三个独力数就可运行,为什么???
...全文
评论 3
收藏 已收藏
分享
返回顶部
tonychoppe
新手乐园 33,315 成员 41,769 内容