home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch12 / point.cpp < prev    next >
C/C++ Source or Header  |  2005-06-16  |  680b  |  33 lines

  1. //              point.cpp
  2. //
  3. // Contains the implementation of the member
  4. // functions for class Point
  5.  
  6. // Include Files
  7. #include <iostream.h>
  8. #include "point.h"                                   // Note 1
  9.  
  10. void Point::display() const                          // Note 2
  11. {
  12.     cout << "(" << x << "," << y << ")";
  13. }
  14.  
  15. bool Point::set_x( int x_val )                       // Note 2
  16. {
  17.     if ( x_val >= 0 ) {
  18.         x = x_val;
  19.         return true;
  20.     }
  21.     x = 0;
  22.     return false;
  23. }
  24.  
  25. bool Point::set_y( int y_val )                       // Note 2
  26. {
  27.     if ( y_val >= 0 ) {
  28.         y = y_val;
  29.         return true;
  30.     }
  31.     y = 0;
  32.     return false;
  33. }