Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef CPOINT_H
- #define CPOINT_H
- #include "cvector2d.h"
- #include "cvector3d.h"
- template<class T, class Y>
- class CPoint
- {
- public:
- inline CPoint<T,Y>( T x = (T)0, T y = (T)0 )
- {
- this->position = new Y(x,y);
- } ;
- inline CPoint<T,Y>(const CPoint<T,Y>& point)
- {
- this->position = new Y();
- *this->position = point.getPosition();
- }
- inline CPoint<T,Y>(const Y& vector)
- {
- this->position = new Y();
- *this->position = vector;
- }
- inline Y& getPosition() const { return *this->position; };
- inline void setPosition(const Y & position)
- {
- *this->position = position;
- };
- inline virtual ~CPoint<T,Y>()
- {
- delete this->position;
- };
- virtual inline void operator = (const CPoint<T,Y> & point)
- {
- *this->position = point.getPosition();
- }
- inline friend std::ostream& operator << (std::ostream& out, CPoint<T,Y> & point)
- {
- out << "P1:" << endl << point.getPosition() << endl;
- return out;
- };
- protected:
- Y *position;
- private:
- };
- typedef CPoint<float,CVector2d<float> > Point2f;
- typedef CPoint<float,CVector3d<float> > Point3f;
- typedef CPoint<double,CVector2d<double> > Point2d;
- typedef CPoint<double,CVector3d<double> > Point3d;
Add Comment
Please, Sign In to add comment