単項 - 演算子

#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);
		}
		Comp operator -() {
			Comp c(-_real, -_imag);
			return c;
		}
};

int main() {
	Comp a(1, 2);
	a.out();
	Comp c = -a;
	c.out();
	return 0;
}