home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ANSICPP.ZIP / EX08011.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  441 b   |  20 lines

  1. // ex08011.cpp
  2. // Pointer to class object
  3. #include <iostream.h>
  4.  
  5. class Date {
  6.     int mo, da, yr;
  7. public:
  8.     Date(int m, int d, int y) { mo = m; da = d; yr = y; }
  9.     void display() 
  10.         { cout << '\n' << mo << '/' << da << '/' << yr; }
  11. };
  12.  
  13. main()
  14. {
  15.     Date *dp;            // a date pointer with garbage in it
  16.     Date dt(3,17,90);    // a Date
  17.     dp = &dt;            // put address of date in pointer
  18.     dp->display();        // display date through the pointer
  19. }
  20.