Original Post
I''d like to use reference counts in my objects (similar to DirectX interfaces have). How?
I think I should have one base class:
I just thought of the Release() method. It should be able to delete the object itself? Is "delete this" allowed? It compiles well.
I just want to be sure what I''m doing before I add include this to my code.
class ref
{
int ref_count;
public:
int AddRef()
{
ref_count++
};
int Release()
{
if( --ref_count==0 ) delete this;
}
protected:
virtual ~ref() {};
};
|