private destructor
From: Arve Sollie (codeworks_at_mobilpost.com)
Date: 11/18/03
- Next message: Rick Noelle: "Re: iostreams equivalent to C's fopen "r+""
- Previous message: Mike Wahler: "Re: Private bases"
- Next in thread: lilburne: "Re: private destructor"
- Reply: lilburne: "Re: private destructor"
- Reply: .oO LGV Oo.: "Re: private destructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 Nov 2003 23:06:05 +0100
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 ?
- Next message: Rick Noelle: "Re: iostreams equivalent to C's fopen "r+""
- Previous message: Mike Wahler: "Re: Private bases"
- Next in thread: lilburne: "Re: private destructor"
- Reply: lilburne: "Re: private destructor"
- Reply: .oO LGV Oo.: "Re: private destructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|