home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-3.ZIP / EXAMPLES.ZIP / POINT.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  1KB  |  35 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // POINT.CPP - Example from Getting Started
  4. //             Illustrates a simple Point class 
  5.  
  6. #include <iostream.h>    // needed for C++ I/O
  7.  
  8. class Point {        // define Point class
  9.    int X;               // X and Y are private by default
  10.    int Y;
  11. public:
  12.    Point(int InitX, int InitY) {X = InitX; Y = InitY;}
  13.    int GetX() {return X;}  // public member functions
  14.    int GetY() {return Y;}
  15. };
  16.  
  17. int main()
  18. {
  19.    int YourX, YourY;
  20.  
  21.    cout << "Set X coordinate: ";  // screen prompt
  22.    cin >> YourX;                  // keyboard input to YourX
  23.  
  24.    cout << "Set Y coordinate: ";  // another prompt
  25.    cin >> YourY;                  // key value for YourY
  26.  
  27.    Point YourPoint(YourX, YourY);  // declaration calls constructor
  28.  
  29.    cout << "X is " << YourPoint.GetX(); // call member function
  30.    cout << '\n';                        // newline
  31.    cout << "Y is " << YourPoint.GetY(); // call member function
  32.    cout << '\n';
  33.    return 0;
  34. }
  35.