home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12560 < prev    next >
Encoding:
Text File  |  1992-08-19  |  2.4 KB  |  74 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sun4nl!utrcu1!infnews!infnews!pool
  3. From: pool@cs.utwente.nl (Sander Pool)
  4. Subject: Re: Problem with 'automatic' destructors
  5. Message-ID: <1992Aug19.162647@cs.utwente.nl>
  6. Keywords: destructor
  7. Sender: usenet@cs.utwente.nl
  8. Nntp-Posting-Host: utis116
  9. Organization: University of Twente, Dept. of Computer Science
  10. References:  <1992Aug19.145847@cs.utwente.nl>
  11. Date: Wed, 19 Aug 1992 14:26:47 GMT
  12. Lines: 60
  13.  
  14. In article <1992Aug19.145847@cs.utwente.nl>, pool@cs.utwente.nl (Sander Pool) writes:
  15. |> hello,
  16. |> 
  17. |> I'm having a 'little' problem with destructors which are called
  18. |> automatically when 'exit()' is called. For some reason the object
  19. |> has turned to garbadge (e.g. the attributes have illegal values)
  20. |> before the destructor is called. This results in funny/disasterous
  21. |> situations. xdbx doesn't help much, when I trap the call to the
  22. |> destructor and try to examine attributes he won't even show them.
  23. |> 
  24. |> The class structure looks like this (where Problem is the problem class):
  25. |> 
  26. |> class Problem {
  27. |> public:
  28. |>     ~Problem(); // this gets called with a bogus object
  29. |> };
  30. |> 
  31. |> class Super {
  32. |> protected:
  33. |>     Problem problem;
  34. |> };
  35. |> 
  36. |> class Action: public xview_class, public Super;
  37. |> 
  38. |> 
  39. |> I create an automatic instance of Action like this
  40. |> 
  41. |> Action    action;        // obvious :-)
  42. |> 
  43. |> and the somewhere in an eventhandler I call 'exit(0)'.
  44. |> 
  45. |> 
  46. |> I'm at a total loss and hope someone can help me out. I
  47. |> use cfront 2.1 on a Sparc.
  48. |> 
  49. |> thanks in advance and regards,
  50. |>     
  51. |>     Sander
  52. |> 
  53. |> ******************************************************************
  54. |> Sander O. Pool         Twente University, 
  55. |>             department of Computer Science 
  56. |>             SETI group / TRESE project    H303
  57. |> __________________________________________________________________
  58. |> address:PO Box 217         | misc.    phone     +31-53-893715
  59. |>     7500 AE Enschede     |    fax    +31-53-356531
  60. |>     The Netherlands     |    email     pool@cs.utwente.nl
  61. |> ******************************************************************
  62. |> 
  63. |> 
  64. |> 
  65.  
  66. OK, this seems a bit silly, replying to my own post, but I've got
  67. some additional info. I added a destructor to class Action which doesn't
  68. do anything but resetting it's attributes to 0. Now the destructor of
  69. Problem gets called properly. This solves my problem but doesn't
  70. explain why it occurs. Any clues?
  71.  
  72. thanks,
  73.         sander
  74.