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

  1. // Triple
  2. // Demonstrates function overloading
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int triple(int number);
  10. string triple(string text);
  11.  
  12. int main()
  13. {
  14.     cout << "Tripling 5: " << triple(5) << "\n\n";
  15.     cout << "Tripling 'gamer': " << triple("gamer");
  16.  
  17.     return 0;
  18. }
  19.  
  20. int triple(int number)
  21. {
  22.     return (number * 3);
  23. }
  24.  
  25. string triple(string text)
  26. {
  27.     return (text + text + text);
  28. }
  29.  
  30.