sashomaga

Template

Feb 24th, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. class calc
  2. {
  3.   public:
  4.     int multiply(int x, int y);
  5.     int add(int x, int y);
  6.  };
  7. int calc::multiply(int x, int y)
  8. {
  9.   return x*y;
  10. }
  11. int calc::add(int x, int y)
  12. {
  13.   return x+y;
  14. }
  15.  
  16. template <class A_Type> class calc
  17. {
  18.   public:
  19.     A_Type multiply(A_Type x, A_Type y);
  20.     A_Type add(A_Type x, A_Type y);
  21. };
  22. template <class A_Type> A_Type calc<A_Type>::multiply(A_Type x,A_Type y)
  23. {
  24.   return x*y;
  25. }
  26. template <class A_Type> A_Type calc<A_Type>::add(A_Type x, A_Type y)
  27. {
  28.   return x+y;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment