Advertisement
Felanpro

template functions with parameters

Apr 24th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <class FIRST, class SECOND>
  6. FIRST smaller(FIRST a, SECOND b) //FIRST is there for the return type!!!!!!
  7. {
  8.     return(a < b ? a : b);
  9. }
  10.  
  11. int main()
  12. {
  13.     int x = 89;
  14.     double y = 56.98;
  15.     cout << smaller(x,y) << endl;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement