home *** CD-ROM | disk | FTP | other *** search
- // ex08011.cpp
- // Pointer to class object
- #include <iostream.h>
-
- class Date {
- int mo, da, yr;
- public:
- Date(int m, int d, int y) { mo = m; da = d; yr = y; }
- void display()
- { cout << '\n' << mo << '/' << da << '/' << yr; }
- };
-
- main()
- {
- Date *dp; // a date pointer with garbage in it
- Date dt(3,17,90); // a Date
- dp = &dt; // put address of date in pointer
- dp->display(); // display date through the pointer
- }