A
Arve Sollie
class myClass
{
private:
int refCount;
~myClass();
public:
myClass();
void incRefCount() { ++refCount; }
void decRefCount() { if (--refCount <=0) delete this; }
};
The purpose of the private destructor is to catch any attempts to
delete the object while still referenced, but my compiler warns me
that I have only private destructors and no friends.
I can of course add a dummy friend, but is this really neccessary ?
{
private:
int refCount;
~myClass();
public:
myClass();
void incRefCount() { ++refCount; }
void decRefCount() { if (--refCount <=0) delete this; }
};
The purpose of the private destructor is to catch any attempts to
delete the object while still referenced, but my compiler warns me
that I have only private destructors and no friends.
I can of course add a dummy friend, but is this really neccessary ?