// Author: Keith A. Shomper // Date: 11/17/03 // Purpose: To deminstrate classes and attribute access #include #include "complex_v3.h" using namespace std; int main () { complex_number x(1, 2), y, z; complex_number sum, difference, product, quotient; // y = complex_number(2, 4); // z = complex_number(3, 0); cout << "Please enter a value for y: "; cin >> y; cout << "Please enter a value for z: "; cin >> z; cout << "x is: " << x << endl; cout << "y is: " << y << endl; cout << "z is: " << z << endl; sum = x + y; difference = x - y; product = x * y; quotient = sum / z; cout << "The sum (x + y) is: " << sum << endl; cout << "The difference (x - y) is: " << difference << endl; cout << "The product (x * y) is: " << x * y << endl; cout << "The quotient (sum / z) is: " << quotient << endl; cout << "x is " << ((x == y) ? "" : "not ") << "equal to y\n"; cout << "x is " << ((x != y) ? "not " : "") << "equal to y\n"; cout << "The real part of x is " << x.real() << " and the imaginary part is " << x.imag() << endl; return 0; }