home *** CD-ROM | disk | FTP | other *** search
- // ex03001.cpp
- // The C++ free store: the new and delete operators
- #include <iostream.h>
-
- struct date { // a date structure
- int month;
- int day;
- int year;
- };
-
- main()
- {
- date *birthday = new date; // get memory for a date
- birthday->month = 6; // assign a value to the date
- birthday->day = 24;
- birthday->year = 1940;
- cout << "I was born on " // display the date
- << birthday->month << '/'
- << birthday->day << '/'
- << birthday->year;
- delete birthday; // return memory to the free store
- }