home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18347 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.3 KB  |  43 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Testing a pointer??
  5. Message-ID: <1992Dec23.150915.4205@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1h5p6eINNdva@fido.asd.sgi.com>
  10. Date: Wed, 23 Dec 1992 15:09:15 GMT
  11. Lines: 30
  12.  
  13. In article <1h5p6eINNdva@fido.asd.sgi.com> davep@paladin.corp.sgi.com (David Packer) writes:
  14. >
  15. >Hey,
  16. >
  17. >If I have a linked-list, called llist...and I want to test it
  18. >to see if it exists. i.e. I only want to create it if needed..
  19. >
  20. >How do I test to see if it exists..
  21. >
  22. >i.e.
  23. >
  24. >if(!llist) { objList = new llist; }
  25. >
  26. >this doesn't seem to work for me??
  27.  
  28.     Not surpising, you cant make up your mind if llist is a type
  29. of an object or what :-)
  30.  
  31.     class List { ...
  32.     List *lp=0;
  33.     ...
  34.     if(lp==0) lp = new List; // lp is created now if it wasnt before   
  35.     assert(lp); 
  36.     // lp now exists
  37.  
  38. -- 
  39. ;----------------------------------------------------------------------
  40.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  41.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  42. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  43.