The KcsShareable class allows derivatives to be shared by other objects in the system. This class uses reference counting. It follows all of the typical C++ semantics, except you should use the dettach()() method instead of calling the destructor ~KcsShareable()(). The dettach()() method calls the destructor only if it is the last object sharing the derivative.
Using a shareable derivative is similar to using a non-shareable objects with the following exceptions:
When you want to use a shareable object with another instance, you must use attach()() rather than the constructor.
Use the dettach()() method instead of the delete()() method to delete a sharable object.
The abstraction provided by this class is simple yet powerful. With only a few methods you can share objects. Every time you want to share an object, the usage count is incremented. Any time a shared object is detached, the usage count is decremented.