Code /* TestComplex.cpp CIS 250 David Klick 2009-02-23 Test driver program for Complex number class. */ #include "Complex.h" #include #include using std::cout; using std::cin; using std::endl; using std::boolalpha; void cont(); int main() { Complex c[6] = { Complex(), Complex(5.0,1.0), Complex(2.0,-3.0), Complex(3.0,-4.0), Complex(5.0,1.0)}; int i; for (i=0; i<5; i++) cout << "c[" << i << "] = " << c[i] << '\n'; cout << "Testing math operators:" << endl; cout << "c[1] + c[2] = " << c[1] + c[2] << endl; cout << "c[1] - c[2] = " << c[1] - c[2] << endl; cout << "c[1] * c[2] = " << c[1] * c[2] << endl; cout << "c[2] * c[3] = " << c[2] * c[3] << endl; cout << "c[1] / c[2] = " << c[1] / c[2] << endl; cout << "c[2] / c[3] = " << c[2] / c[3] << endl; cout << "Testing increment and decrement operators:" << endl; cout << "++c[2] = " << ++c[2] << endl; cout << "--c[2] = " << --c[2] << endl; cout << "c[2]++ = " << c[2]++ << endl; cout << "c[2]-- = " << c[2]-- << endl; cout << "c[2] = " << c[2] << endl; cout << "Testing relational and assignment operators:" << endl; cout << boolalpha; cout << "c[0] > c[1] = " << (c[0] > c[1]) << endl; // true cout << "c[0] < c[1] = " << (c[0] < c[1]) << endl; // false cout << "c[0] == c[1] = " << (c[0] == c[1]) << endl; // false cout << "c[0] != c[1] = " << (c[0] != c[1]) << endl; // true cout << "c[1] == c[4] = " << (c[1] == c[4]) << endl; // true cout << "c[0] <= c[1] = " << (c[0] <= c[1]) << endl; // false cout << "c[0] >= c[1] = " << (c[0] >= c[1]) << endl; // true cout << "c[1] >= c[4] = " << (c[1] >= c[4]) << endl; // true cout << "c[1] <= c[4] = " << (c[1] <= c[4]) << endl; // true cout << "Test of extraction operator overload\n"; cin >> c[0]; cout << "You entered: " << c[0] << '\n'; cout << "*** End of test" << endl; cont(); return 0; } void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); }