28 lines
512 B
C++
28 lines
512 B
C++
|
|
#include "refptr.h"
|
|
|
|
template <typename T> refptr<T>::refptr(const T * ptr)
|
|
{
|
|
m_ptr = ptr;
|
|
refCount = new int;
|
|
*refCount = 1;
|
|
}
|
|
|
|
template <typename T> refptr<T>::refptr(const refptr<T> & orig)
|
|
{
|
|
cloneFrom(orig);
|
|
}
|
|
|
|
template <typename T> refptr<T> & refptr<T>::operator=(const refptr<T> & orig)
|
|
{
|
|
cloneFrom(orig);
|
|
return *this;
|
|
}
|
|
|
|
template <typename T> void refptr<T>::cloneFrom(const refptr<T> & orig)
|
|
{
|
|
this->ptr = orig.ptr;
|
|
this->refCount = orig.refCount;
|
|
(*refCount)++;
|
|
}
|