code_junkie

Operations on arbitrary value types

Nov 11th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public T Add(T val1, T val2)
  2. {
  3. return val1 + val2;
  4. }
  5.  
  6. public T Add(T val1, T val2)
  7. {
  8. //Num<T> defines a '+' operation which returns a value of type T
  9. return (new Num<T>(val1) + new Num<T>(val2));
  10. }
  11.  
  12. template < class T >
  13. T add(T const & val1, T const & val2)
  14. {
  15. return val1 + val2;
  16. }
  17.  
  18. template <typename T>
  19. T Add(T val1, T val2)
  20. {
  21. return val1 + val2;
  22. }
  23.  
  24. #define ADD(A,B) (A+B)
  25.  
  26. template<typename T>
  27. T add(T x, T y)
  28. {
  29. return x + y;
  30. }
Add Comment
Please, Sign In to add comment