home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tutorial / cpptutor / answers / ch07_3b.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-15  |  558 b   |  33 lines

  1.                              // Chapter 7 - Programming exercise 3
  2. #include <ch07_3a.h>         // This is actually TRUCK.H
  3.  
  4. void truck::init_truck(int how_many = 2, float max_load = 24000.0)
  5. {
  6.    passenger_load = how_many;
  7.    payload = max_load;
  8. }
  9.  
  10.  
  11. float truck::efficiency(void)
  12. {
  13.    return payload / (payload + get_weight());
  14. }
  15.  
  16.  
  17. int truck::passengers(void)
  18. {
  19.    return passenger_load;
  20. }
  21.  
  22.  
  23. int truck::total_weight(void)
  24. {
  25.    return (payload + get_weight());
  26. }
  27.  
  28.  
  29.  
  30. // Result of execution
  31. //
  32. // (this file cannot be executed)
  33.