Chapter 15 Exercise Set 1ΒΆ

  1. Overload the - operator for Complex objects so that c1 - c2 will subtract two complex objects.

  2. Overload the / operator for Complex objects so that c1 / c2 will divide two complex objects.

  3. Add a member function to Complex named abs that returns the absolute value of the complex number.

  4. Do a web search on how to overload the << operator so that given a complex number c1, the statement:

    cout << c1 << endl;
    

    will display a human readable representation of c1.

  5. Rewrite the Point structure introduced in Point objects as a class with member functions, including overloaded + and - operators for adding and subtracting points. Use what you learned in the previous exercise to overload << for printing times.

  6. Overload the * operator for the Point class you created in the previous exercise two ways: one for scalar multiplication, that has a double as a left operand and a Point as a right operand and returns a Point, and another that computes the dot product of two Point operands, returning a double.

  7. Rewrite the Time structure introduced in Time as a class with member functions, including overloaded + and - operators for adding and subtracting times. Overload << for printing times.