JamesYeoman

CartesianVector CPP

May 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include "CartesianVectors.h"
  2.  
  3. template <typename T> CartesianVector<T>::CartesianVector(T X, T Y)
  4. {
  5.     x = X;
  6.     y = Y;
  7. }
  8.  
  9. template <typename T> CartesianVector<T> CartesianVector<T>::operator+ (const CartesianVector<T> other)
  10. {
  11.     T tempX = this.x + other.x;
  12.     T tempY = this.y + other.y;
  13.     return CartesianVector<T>(tempX, tempY);
  14. }
  15.  
  16. template <typename T> CartesianVector<T> CartesianVector<T>::operator- (const CartesianVector<T> other)
  17. {
  18.     T tempX = this.x - other.x;
  19.     T tempY = this.y - other.y;
  20.     return CartesianVector<T>(tempX, tempY);
  21. }
  22.  
  23. template <typename T> CartesianVector<T> CartesianVector<T>::operator* (const CartesianVector<T> other)
  24. {
  25.     T tempX = this.x * other.x;
  26.     T tempY = this.y * other.y;
  27.     return CartesianVector<T>(tempX, tempY);
  28. }
Add Comment
Please, Sign In to add comment