Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages

# SmartPtr< T > Class Template Reference

Wrapper class of a pointer to class T. It handles the destruction of T. More...

`#include <SmartPtr.h>`

List of all members.

## Detailed Description

### template<class T>
class SmartPtr< T >

Wrapper class of a pointer to class T. It handles the destruction of T.

This class wraps a pointer to on object of class T, an keeps track of the number of references to the same object. When the number of references becomes zero, the referenced object is destroyed.

If the non-constant version of operator->() is called for an object with number of references grater than 1, a copy of the referenced object is performed by calling its member function CreateObject(). This implies that class T must have this function implemented.

The need for requiring a function T::CreateObject() is that we don't know whether we have a pointer to an object T or to a class derived from T. Thus, the only solution is to force T to have a virtual function that will create and copy the correct type of object.

Definition at line 62 of file SmartPtr.h.

The documentation for this class was generated from the following file:

- SmartPtr.h