home *** CD-ROM | disk | FTP | other *** search
- // ex05003.cpp
- // Multiple instances of a structures with a function
- #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 alans_birthday = {4, 6, 1961};
- cout << "\nAlan's date of birth was ";
- alans_birthday.display();
-
- date wendys_birthday = {4, 28, 1965};
- cout << "\nWendy's date of birth was ";
- wendys_birthday.display();
- }