Chapter 14 Exercise Set 0: Chapter Review¶
Overload the
-operator forComplexobjects so thatc1 - c2will subtract two complex objects.Overload the
/operator forComplexobjects so thatc1 / c2will divide two complex objects.Add a member function to
Complexnamedabsthat returns the absolute value of the complex number.Do a web search on how to overload the
<<operator so that given a complex numberc1, the statement:cout << c1 << endl;
will display a human readable representation of
c1.Rewrite the
Pointstructure 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.Overload the
*operator for thePointclass you created in the previous exercise two ways: one for scalar multiplication, that has a double as a left operand and aPointas a right operand and returns aPoint, and another that computes the dot product of twoPointoperands, returning a double.Rewrite the
Timestructure introduced in Time as a class with member functions, including overloaded+and-operators for adding and subtracting times. Overload<<for printing times.