home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch14 / templmid.cpp < prev    next >
C/C++ Source or Header  |  1995-09-18  |  285b  |  15 lines

  1. #include <iostream.h>
  2.  
  3. // This is the function template definition
  4. template <class Type>
  5. Type Middle(Type a, Type b, Type c)
  6. {
  7.     return (a <= b ? (b <= c ? b : Middle(a, c, b)) :
  8.             Middle(b, a, c));
  9. }
  10.  
  11. void main()
  12. {
  13.     cout << "Middle(3, 12, 5) is " << Middle(3, 12, 5);
  14. }
  15.