Add the pure virtual method
virtual bool contains (double x, double y) = 0;
to the GObject class presented in Figure 19-5 and then implement that method for each of the subclasses. For the GRect and GOval subclasses, the contains method should return true if the specified point is inside the object, and false if it is outside. For the GLine class, contains should return true if the point is within half a pixel distance of the line. If you are unsure of how to determine whether a point is inside a GOval or how to calculate the distance from a point to a line, you should do what professional programmers do in such circumstances: look the answer up on the web.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here