template<class T>
class CTJBrewPtr
{
public:
typedef T element_type;
//ctor
explicit CTJBrewPtr(T *pVal = 0) throw()
{
if(pVal)
m_AutoPtr = pVal;
else
m_AutoPtr = NULL;
i = 0;
}
//copy ctor
CTJBrewPtr(const CTJBrewPtr<T>& ptrCopy) throw()
{
if(ptrCopy)
m_AutoPtr = ptrCopy;
else
m_AutoPtr = NULL;
i = 0;
}
//overloading = operator
CTJBrewPtr<T>& operator=(CTJBrewPtr<T>& ptrCopy) throw()
{
if(ptrCopy)
m_AutoPtr = &ptrCopy;
else
m_AutoPtr = 0;
return m_AutoPtr;
}
//dtor
~CTJBrewPtr()
{
if(m_AutoPtr)
{
delete m_AutoPtr;
}
}
//overloading * operator
T& operator*() const throw()
{
return *m_AutoPtr;
}
//overloading -> operator
T *operator->() const throw()
{
return m_AutoPtr;
}
//function to get the pointer to the class
T *get() const throw()
{
return m_AutoPtr;
}
private:
T *m_AutoPtr;
uint32 i;
};