Guest User

Untitled

a guest
Jul 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. template <typename T>
  2. class Vector2
  3. {
  4. ...
  5. template <typename> // объявляем дружественную ф-цию шаблонной
  6. friend Vector2<T> operator +(Vector2<T> const& l_v, Vector2<T> const& r_v);
  7. ...
  8. }
  9.  
  10. template <typename T>
  11. Vector2<T> operator +(Vector2<T> const& l_v, Vector2<T> const& r_v)
  12. { ... }
  13.  
  14. template <typename> Vector2<T> operator+(Vector2 < T >
  15.  
  16. const & l_v,
  17.  
  18. Vector2<T> const& r_v
  19.  
  20. )
  21. {
  22. return
  23. Vector2<T>();
  24. }
  25. // да-да, именно в таком виде, со всеми отступами
  26.  
  27. template <typename>
  28. friend Vector2<T> operator +(Vector2<T> const& l_v, Vector2<T> const& r_v);
  29.  
  30. template <typename U>
  31. friend Vector2<T> operator +(Vector2<T> const& l_v, Vector2<T> const& r_v);
  32.  
  33. template <typename U>
  34. friend Vector2<int> operator +(Vector2<int> const& l_v, Vector2<int> const& r_v);
  35.  
  36. template <typename T>
  37. Vector2<T> operator +(Vector2<T> const& l_v, Vector2<T> const& r_v)
  38. { ... }
  39.  
  40. template <typename T>
  41. class Vector2
  42. {
  43. ...
  44. template <typename U> // объявляем дружественную ф-цию шаблонной
  45. friend Vector2<U> operator +(Vector2<U> const& l_v, Vector2<U> const& r_v);
  46. ...
  47. };
Add Comment
Please, Sign In to add comment