#pragma once #include #include "../util/debug.h" template struct SmartPointer{ Object *ref; int counter; ~SmartPointer(){ print("SmartPointer Desctructor called") if(counter==0){ delete ref; } } }; template using SPointer = struct SmartPointer; template class Box { public: Box(Object *); //constructor ~Box(); //destructor Box(const Box&); //copy constructor Object *operator->(); Object *operator*(); //deref operator int getRefCounter(){ return this->sref->counter; }; friend std::ostream &operator<<(std::ostream &stream, Box const &c) { return stream << "Boxed[v=" << *c.sref->ref << ",r=" << c.sref->ref << "]"; } private: SPointer* sref; }; template class Point2D { private: Number _x; Number _y; public: Point2D(Number x, Number y) : _x(x), _y(y){ print("Point2D default constructor called: " << this)}; //Default constructor Point2D(const Point2D &); //Copy constructor Point2D(Point2D &&); //Move constructor ~Point2D(); //Destructor friend std::ostream &operator<<(std::ostream &stream, Point2D const &c) { return stream << "(" << c._x << "," << c._y << ")"; } Number getX() { return _x; } Number getY() { return _y; } };