/* This next statement uses the overloaded operator=(SmartPtr&) defined below
* to decrement the reference count for the
* old Target object used by this class and increment the
* usage count for the new Target object.
*/ *this= dp; }
/* This next statement uses the overloaded operator=(Target *) defined below
* to decrement the reference count for the
* old Target object used by this class and increment the
* usage count for the new Target object.
*/ *this= dp; }
SmartPtr::~SmartPtr() { // This will cause a decrement of the Target reference count
// via the operator=(Target *) defined below
*this=(Target *) 0L; }
SmartPtr& SmartPtr::operator=(const SmartPtr& newPtr) { // This has the effect of calling the overloaded operator=(Target *)
// method which adjusts the Target reference count
SmartPtr& SmartPtr::operator=(Target *newTgt) { /* This method is the main method keeping track of the
* reference count for the associated Target object.
*/
// If the pointer passed is not null then bump up the reference
// count for the source Target.
if(newTgt != 0L ) {
newTgt->incrRefCount(); }
// If the pointer this object is currently using is not null
// then decrement the count for that pointer.
if(m_tgtPtr != 0L ){
// If the count has reached zero, then it is time to delete this