/Wskazówka 59.
template <class T> class ObjectSmartPointer : public BaseSmartPointer <T>
private:
// Prywatne, aby uniemożliwić innym użycie konstruktora kopiowania. ObjectSmartPointer(ObjectSmartPointer<T>&osp)
public:
ObjectSmartPointer(T* pt=NULL) : BaseSmartPointer<T>(pt)
T* operator=(T *pt)
return BaseSmartPointer<T>::operator=(pt);
T *operator->() const
return m_pt;
class foo
public: int i; float f;
Smartptr.cpp
#include "smartptr.h"
#include "iostream.h" void TestSmartPointer(void)
BaseSmartPointer<int> pi; ObjectSmartPointer<foo> po;
po = new foo; po->i = 10; po->f = 10.5;
cout « (*po).i « "" « po->f « "\n"; pi = new int; pi = new int;