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

  1. // ex05003.cpp
  2. // Multiple instances of a structures with a function
  3. #include <iostream.h>
  4.  
  5. // ------  structure with a function
  6. struct date {
  7.     int month, day, year;
  8.     void display(void);       // a function to display the date
  9. };
  10.  
  11. void date::display()
  12. {
  13.     static char *mon[] = {
  14.         "January","February","March","April","May","June",
  15.         "July","August","September","October","November",
  16.         "December"};
  17.     cout << mon[month-1] << " " << day << ", " << year;
  18. }
  19.  
  20. main()
  21. {
  22.     date alans_birthday = {4, 6, 1961};
  23.     cout << "\nAlan's date of birth was ";
  24.     alans_birthday.display();
  25.  
  26.     date wendys_birthday = {4, 28, 1965};
  27.     cout << "\nWendy's date of birth was ";
  28.     wendys_birthday.display();
  29. }
  30.