Guest User

Untitled

a guest
Apr 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #ifndef CPOINT_H
  2. #define CPOINT_H
  3.  
  4. #include "cvector2d.h"
  5. #include "cvector3d.h"
  6.  
  7. template<class T, class Y>
  8. class CPoint
  9. {
  10.  
  11. public:
  12. inline CPoint<T,Y>( T x = (T)0, T y = (T)0 )
  13. {
  14. this->position = new Y(x,y);
  15. } ;
  16.  
  17. inline CPoint<T,Y>(const CPoint<T,Y>& point)
  18. {
  19. this->position = new Y();
  20. *this->position = point.getPosition();
  21. }
  22.  
  23. inline CPoint<T,Y>(const Y& vector)
  24. {
  25. this->position = new Y();
  26. *this->position = vector;
  27. }
  28.  
  29. inline Y& getPosition() const { return *this->position; };
  30. inline void setPosition(const Y & position)
  31. {
  32. *this->position = position;
  33. };
  34.  
  35. inline virtual ~CPoint<T,Y>()
  36. {
  37. delete this->position;
  38. };
  39.  
  40. virtual inline void operator = (const CPoint<T,Y> & point)
  41. {
  42. *this->position = point.getPosition();
  43. }
  44.  
  45. inline friend std::ostream& operator << (std::ostream& out, CPoint<T,Y> & point)
  46. {
  47. out << "P1:" << endl << point.getPosition() << endl;
  48. return out;
  49. };
  50.  
  51. protected:
  52. Y *position;
  53. private:
  54. };
  55.  
  56. typedef CPoint<float,CVector2d<float> > Point2f;
  57. typedef CPoint<float,CVector3d<float> > Point3f;
  58. typedef CPoint<double,CVector2d<double> > Point2d;
  59. typedef CPoint<double,CVector3d<double> > Point3d;
Add Comment
Please, Sign In to add comment