home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13422 < prev    next >
Encoding:
Text File  |  1992-09-09  |  1.6 KB  |  45 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!sunic!ericom!etn.ericsson.se!etn.ericsson.se!bjs
  3. From: bjs@etn.ericsson.se (Bj|rn S{ter|y 1342)
  4. Subject: Deleting NIHCL Objects
  5. Message-ID: <1992Sep9.110455.17143@etn.ericsson.se>
  6. Keywords: virtual destructors 
  7. Sender: news@etn.ericsson.se
  8. Reply-To: bjs@etn.ericsson.se (Bj|rn S{ter|y 1342)
  9. Organization: Ericsson Telecom A/S
  10. Date: Wed, 9 Sep 92 11:04:55 GMT
  11. Lines: 32
  12.  
  13. i have implemented a set making use of the NIHCL Set class,
  14. and several objects derived from the NIHCL class Object which
  15. are added to the set using the add(Object *) method.
  16.  
  17. i soon found out that deleting the set though ~Set destructor
  18. did not delete the objects in the set. i therefore tried to
  19. iterate through the set deleting the objects in the set through
  20. the individual Object pointers. this did however not release the
  21. memory allocated by the derived objects, because the ~Object
  22. destructor is not virtual.
  23.  
  24. most everything else about NIHCL seems very well designed, and i
  25. can accept the fact that deleting the Set not automatically deletes
  26. the individual objects, but the non virtual ~Object "feature" surprised
  27. me.
  28.  
  29. i am hesitant to modify the NIHCL source code to make the ~Object 
  30. virtual, due to any possible error that it might cause for other
  31. parts of the library.
  32.  
  33. has anybody else seen/considered this "feature"? 
  34. is it there for a good reason that i don't see?
  35. is it possible to "fix" (i.e. by just making the ~Object virtual)?
  36.  
  37. regards,
  38. bjorn.
  39.  
  40. ---------------------------------
  41. - Bjorn.Sateroy@etn.ericsson.se -
  42. - Ericsson Telecom AS, Norway   -
  43. ---------------------------------
  44.   
  45.