Smartptr.h
#include <stdio.h>
//Wskazówka 58.
//Wskazówka 60.
template <dass T> class BaseSmartPointer
private:
// Konstruktor kopiowania i operator = są prywatne, aby uniknąć kopiowania // wskaźników między dwoma inteligentnymi wskaźnikami. BaseSmartPointer<T>&operator=(BaseSmartPointer<T>&bsp)
return *this;
BaseSmartPointer(BaseSmartPointer<T>&bsp)
protected:
T *m_pt; public:
BaseSmartPointer(T *pt=NULL) : m_pt(pt)
virtual ~BaseSmartPointer()
if(m_pt)
delete m_pt; m_pt = NULL;
T &operator*() const
return *m_pt;
T*operator=(T *pt)
if(m_pt)
delete m_pt; m_pt = pt; return m_pt;
};