#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <algorithm>


typedef struct complex
{
	complex(double re, double im)
		: re(re), im(im) {}
	void swap(complex & other);
	complex & operator=(complex const& other);
	void print();
private:
	double re;
	double im;
} complex;

void complex::swap(complex & other)
{
	using std::swap;
	swap(re, other.re);
	swap(im, other.im);
}

complex & complex::operator=(complex const& other)
{
	if (this != &other)
		complex(other).swap(*this);
	return *this;
}

void complex::print()
{
	std::cout << re << ", " << im << std::endl;
}

int main()
{
	complex x(0, 1);
	complex y(0, -1);

	x.print();
	y.print();

	x = y;
	x.print();
}