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

  1. // ex03001.cpp
  2. // The C++ free store: the new and delete operators
  3. #include <iostream.h>
  4.  
  5. struct date {        // a date structure
  6.     int month;
  7.     int day;
  8.     int year;
  9. };
  10.  
  11. main()
  12. {
  13.     date *birthday = new date;    // get memory for a date
  14.     birthday->month = 6;          // assign a value to the date
  15.     birthday->day = 24;
  16.     birthday->year = 1940;
  17.     cout << "I was born on "              // display the date
  18.          << birthday->month << '/'
  19.          << birthday->day   << '/'
  20.          << birthday->year;
  21.     delete birthday;        // return memory to the free store
  22. }
  23.