关于重载运算符和结构体

· · 个人记录

粘上代码,自己思考去吧!!!

(因为我自己也不懂!!!)

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
struct Add{
    int b;

    void read()
    {
        cin>>b;
    }
    void print()
    {
        cout<<b;
    }
    Add operator + (Add& c) {
        Add x;
        x.b= b+c.b;
        return x;
    }
}; 
int main()
{
    Add n,m;
    n.read(); m.read();
    Add t;
    t=n+m;
    t.print();
    return 0;
}