home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CPTUTOR2.ZIP / ANSWERS.ARC / CH11_1B.CPP < prev    next >
C/C++ Source or Header  |  1990-07-20  |  2KB  |  96 lines

  1.                              // Chapter 10 - Programming exercise 1
  2. #include "supervsr.hpp"
  3. #include "iostream.h"
  4.  
  5. // In all cases, init_data assigns values to the class variables and
  6. //  display outputs the values to the monitor for inspection.
  7.  
  8. void
  9. supervisor::init_data(char in_name[], int in_salary, char in_title[])
  10. {
  11.    strcpy(name,in_name);
  12.    salary = in_salary;
  13.    strcpy(title, in_title);
  14. }
  15.  
  16.  
  17.  
  18.  
  19. void
  20. supervisor::display(void)
  21. {
  22.    cout << "Supervisor --> " << name << "'s salary is " << salary <<
  23.                                  " and is the " << title << ".\n\n";
  24. }
  25.  
  26.  
  27.  
  28.  
  29. void
  30. programmer::init_data(char in_name[], int in_salary, char in_title[],
  31.                   char in_language[])
  32. {
  33.    strcpy(name,in_name);
  34.    salary = in_salary;
  35.    strcpy(title, in_title);
  36.    strcpy(language, in_language);
  37. }
  38.  
  39.  
  40.  
  41.  
  42. void
  43. programmer::display(void)
  44. {
  45.    cout << "Programmer --> " << name << "'s salary is " << salary <<
  46.                                         " and is " << title << ".\n";
  47.    cout << "               " << name << "'s specialty is " << 
  48.                                                  language << ".\n\n";
  49. }
  50.  
  51.  
  52.  
  53.  
  54. void
  55. secretary::init_data(char in_name[], int in_salary, 
  56.                              char in_shorthand, char in_typing_speed)
  57. {
  58.    strcpy(name,in_name);
  59.    salary = in_salary;
  60.    shorthand = in_shorthand;
  61.    typing_speed = in_typing_speed;
  62. }
  63.  
  64.  
  65.  
  66.  
  67. void
  68. secretary::display(void)
  69. {
  70.    cout << "Secretary ---> " << name << "'s salary is " << salary <<
  71.                                                                  ".\n";
  72.    cout << "               " << name << " types " << typing_speed <<
  73.               " per minute and can ";
  74.    if (!shorthand) cout << "not ";
  75.    cout << "take shorthand.\n\n";
  76.  
  77.  
  78.  
  79. void
  80. consultant::init_data(char in_name[], int in_salary, char in_title[])
  81. {
  82.    strcpy(name,in_name);
  83.    salary = in_salary;
  84.    strcpy(title, in_title);
  85. }
  86.  
  87.  
  88.  
  89.  
  90. void
  91. consultant::display(void)
  92. {
  93.    cout << "Consultant --> " << name << "'s salary is " << salary <<
  94.                                  " and is the " << title << ".\n\n";
  95. }
  96.