简单的重载运算符

#include<iostream>

using namespace std;

class Complex{
public:
    int a, b;
    Complex(int _a, int _b) : a(_a), b(_b) {}

    Complex operator + (const Complex& complex){
        return Complex(a + complex.a, b + complex.b);
    }
};

int main(){
    int m;
    int a1, b1, a2, b2;
    cin >> m;
    for(int i = 0; i < m; i ++){
        cin >> a1 >> b1 >> a2 >> b2;
        Complex c1(a1, b1), c2(a2, b2);
        c1 = c1 + c2;
        if(c1.b > 0)
            printf("%d+%di\n", c1.a, c1.b);
        else printf("%d%di\n", c1.a, c1.b);
    }
    return 0;
}