home *** CD-ROM | disk | FTP | other *** search
/ Beginning C++ Through Gam…rogramming (2nd Edition) / BCGP2E.ISO / source / chapter05 / taking_damage.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-04-11  |  663 b   |  32 lines

  1. // Taking Damage
  2. // Demonstrates function inlining
  3.  
  4. #include <iostream>
  5.  
  6. int radiation(int health);
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     int health = 80;
  13.     cout << "Your health is " << health << "\n\n";
  14.     
  15.     health = radiation(health);
  16.     cout << "After radiation exposure your health is " << health << "\n\n";
  17.     
  18.     health = radiation(health);
  19.     cout << "After radiation exposure your health is " << health << "\n\n";
  20.     
  21.     health = radiation(health);
  22.     cout << "After radiation exposure your health is " << health << "\n\n";
  23.     
  24.     return 0;
  25. }
  26.  
  27. inline int radiation(int health)
  28. {
  29.     return (health / 2);
  30. }
  31.  
  32.