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

  1. // ex05002.cpp
  2. // Structures with functions
  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 birthday = {4, 6, 1961};
  23.     cout << "Alan's date of birth was ";
  24.     birthday.display();
  25. }
  26.