home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
- Subject: Re: How to prevent local instances, but allow "new"
- Reply-To: nikki@trmphrst.demon.co.uk
- References: <1icij0INNdhc@news.cerf.net>
- Distribution: world
- X-Mailer: cppnews $Revision: 1.30 $
- Organization: Trumphurst Ltd.
- Lines: 16
- Date: Wed, 6 Jan 1993 12:22:34 +0000
- Message-ID: <726348154snx@trmphrst.demon.co.uk>
- Sender: usenet@demon.co.uk
-
- In article <1icij0INNdhc@news.cerf.net> hlf@nic.cerf.net (Howard Ferguson) writes:
- > I wish to define a class in a library which the library user
- > can create by dynamic allocation via the new operator, but
- > I want to prevent him from creating automic instances.
-
- Leave the constructors public. Make the DESTRUCTOR private. Provide an
- inline member function ...
-
- void destroy() { delete this; }
-
- Users have to call destroy instead of delete, but they won't be able to
- create automatic, static or extern objects of the class.
-
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-