178 Introduction to C++ Programming and Graphics
Problems
6.11.1. (a) Overload the ++ operator such that a point is reflected with respect
to theyaxis. (b) Overload the – operator such that a point is reflected
with respect to thexaxis.
6.11.2. Define the class of all points in three-dimensional space by analogy to
the class of points in the plane discussed in the text.
6.11.3. Define the class of complex numbersx=x+iy, whereiis the imaginary
unit,i^2 =−1. Implement member functions that carry out addition,
subtraction, multiplication, and division.
6.12 The class of runners
An international sports competition has been subscribed by runners originating
from all over the world. Each runner is recorded by his/her name, country of
origin, and performance time. The runners are placed to the “runner” class
that is defined as follows:
class runner
{
public:
runner();
runner(string runnername, string runnercountry,
double runnertime);
void read();
string getname() const;
string getcountry() const;
double gettime() const;
void print() const;
private:
string name;
string country;
double time;
};
The implementation of the default constructor is:
runner::runner()
{
name = "Euripides";
country = "Nigeria";
time = 9.9;
}
where 9.9 is a default time in seconds.