home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Testing a pointer??
- Message-ID: <1992Dec23.150915.4205@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1h5p6eINNdva@fido.asd.sgi.com>
- Date: Wed, 23 Dec 1992 15:09:15 GMT
- Lines: 30
-
- In article <1h5p6eINNdva@fido.asd.sgi.com> davep@paladin.corp.sgi.com (David Packer) writes:
- >
- >Hey,
- >
- >If I have a linked-list, called llist...and I want to test it
- >to see if it exists. i.e. I only want to create it if needed..
- >
- >How do I test to see if it exists..
- >
- >i.e.
- >
- >if(!llist) { objList = new llist; }
- >
- >this doesn't seem to work for me??
-
- Not surpising, you cant make up your mind if llist is a type
- of an object or what :-)
-
- class List { ...
- List *lp=0;
- ...
- if(lp==0) lp = new List; // lp is created now if it wasnt before
- assert(lp);
- // lp now exists
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-