~SmartPointer();
/**
- * Assignment operator. Change of
+ * Assignment operator for
+ * normal pointers. Change of
* subscription is necessary.
*/
SmartPointer<T> & operator= (T *tt);
-
+
+ /**
+ *Assignment operator for
+ * #SmartPointer#. Change of
+ * subscription is necessary.
+ */
+ SmartPointer<T> & operator= (const SmartPointer<T>& tt);
/**
* Conversion to normal pointer.
* Pointer to the object we want
* to subscribt to.
*/
- const T* t;
+ T * t;
};
};
+template <typename T>
+SmartPointer<T> & SmartPointer<T>::operator = (const SmartPointer<T>& tt) {
+ if (t)
+ t->unsubscribe();
+ t = (T*) tt;
+ if (tt)
+ tt->subscribe();
+ return *this;
+};
+
template <typename T>
inline
In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move.
Douglas Adams