home *** CD-ROM | disk | FTP | other *** search
- // ex05002.cpp
- // Structures with functions
- #include <iostream.h>
-
- // ------ structure with a function
- struct date {
- int month, day, year;
- void display(void); // a function to display the date
- };
-
- void date::display()
- {
- static char *mon[] = {
- "January","February","March","April","May","June",
- "July","August","September","October","November",
- "December"};
- cout << mon[month-1] << " " << day << ", " << year;
- }
-
- main()
- {
- date birthday = {4, 6, 1961};
- cout << "Alan's date of birth was ";
- birthday.display();
- }