Chapter 15 Exercise Set 0: Chapter ReviewΒΆ
Overload the
-
operator forComplex
objects so thatc1 - c2
will subtract two complex objects.Overload the
/
operator forComplex
objects so thatc1 / c2
will divide two complex objects.Add a member function to
Complex
namedabs
that 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
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.Overload the
*
operator for thePoint
class you created in the previous exercise two ways: one for scalar multiplication, that has a double as a left operand and aPoint
as a right operand and returns aPoint
, and another that computes the dot product of twoPoint
operands, returning a double.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.