#include <stdio.h> class Comp { double _real; double _imag; public : Comp(double real = 0.0, double imag = 0.0) { _real = real; _imag = imag; } void out() { printf("(%f, %f)\n", _real, _imag); } friend Comp operator +(Comp a, Comp b); }; Comp operator +(Comp a, Comp b) { Comp c; c._real = a._real + b._real; c._imag = a._imag + b._imag; return c; } int main() { Comp a(1, 2); Comp b(2, 3); a.out(); b.out(); Comp c = a + b; c.out(); return 0; }