// Test of the complex class // Michael Rothstein // 07/27/2014 #include #include "Complex.h" using std::cin; using std::cout; using std::endl; const Complex I(0,1); void print(Complex a){ cout << a.real() << " + " << a.imag() << "*I "; } int main(){ Complex one(1,1),two(2,2),three(3,3),four(4,4); Complex a = two+three*I; Complex b = one +I; Complex i = I; Complex c = three + four*I - i*I; cout << "a = "; print(a); cout << endl; cout << " a *I = "; print(a*I); cout << endl; cout << "b = "; print(b); cout << endl; cout << " b *I = "; print(b*I); cout << endl; cout << "c = "; print(c); cout << endl; cout << " c *I = "; print(c*I); cout << endl; cout << "I = "; print(i); cout << "\nI*I = "; print(i * i); cout << endl; if ( a + b == c ) { cout << "It works!\n"; } else { cout << "Something failed.\n"; cout << "a = "; print(a); cout << "b = "; print(b); cout << "\na + b = "; print(a+b); cout << "\nc = "; print(c); cout << endl; } return 0; }