个人作业

#include<iostream> 
#include<string> 
using namespace std; 
class jz; 
istream &operator >> (istream &is,jz &c); 
ostream &operator << (ostream &os,jz &c); 
class jz{ 
public:
    jz(){};
    friend jz operator + (const jz &a, const jz &b);   //friend 
    friend ostream &operator << (ostream &,jz &); 
    friend istream &operator >> (istream &,jz &); 
    jz(int a,int b,int c,int d,int e,int f)  {d1=a;d2=b;d3=c;d4=d;d5=e;d6=f;} 
private:
 int d1,d2,d3,d4,d5,d6;
}; 
ostream & operator << (ostream &output,jz &c)
{
 output << c.d1 << " " << c.d2 <<" " << c.d3 <<endl; 
    cout << c.d4 << " " << c.d5 <<" " << c.d6 <<endl; 
    return output;
}
istream & operator >> (istream &input,jz &c) 

    input>> c.d1 >> c.d2 >> c.d3 >> c.d4 >> c.d5 >> c.d6; 
    return input; 

jz operator + (const jz &a, const jz &b) 

    int a1=a.d1+b.d1; 
    int a2=a.d2+b.d2; 
    int a3=a.d3+b.d3; 
    int a4=a.d4+b.d4; 
    int a5=a.d5+b.d5; 
    int a6=a.d6+b.d6; 
    return jz(a1,a2,a3,a4,a5,a6); 
}




int main()
{
 jz a,b,c;
 cout << "Please input six number to jz1:"<< endl;
    cin >> a; 
    cout << "Please input six number to jz2:"<< endl;
    cin >> b; 
    c=a+b; 
    cout << "c=a+b" <<endl;
    cout << c <<endl;
    return 0; 
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值