home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16325 < prev    next >
Encoding:
Internet Message Format  |  1992-11-15  |  2.7 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!warwick!bham!bhamvx!mccauleyba
  2. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Interobject member function calls while in construction
  5. Message-ID: <1992Nov15.182711.1@vax1.bham.ac.uk>
  6. Date: 15 Nov 92 18:27:11 GMT
  7. References: <1509TB8w165w@rhps.chi.il.us>
  8. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  9. Organization: University of Birmingham
  10. Lines: 35
  11.  
  12. In article <1509TB8w165w@rhps.chi.il.us>, warlok@rhps.chi.il.us (Jon L Fincher) writes:
  13. > So, now the situation is this - I have a member function screen::init()
  14. > constructing a window.  window::window() calls other owned member functions
  15. > (not a problem, right?) and some functions in screen (again, not a problem?).
  16. > However, some member functions in screen call window member functions, which
  17. > has, at this time, not finished instantiation.
  18. > Should this cause lot's of problems?  If so, I can devise a suitable
  19. > workaround, but I want to keep the initialization member functions to a
  20. > minumum, prefereably one per class.  Worst case scenario - redesign of basic
  21. > structure.  Any help?  Code can be provided, if needed.
  22. There should be no problem using a partially constructed object provided you
  23. are aware that this is what is happening. I can't quite see how you can get
  24. into the situation you describe as `screen::init()' must call
  25. `window::window()' as part of a `new' expression and as this expression
  26. has not completed I don't quite see how the `screen' class can call members
  27. of `window' as at this point it still has no pointers to `window's.
  28. Unless of course `screen' is calling static members of `window'. (You
  29. did say all objects of type `window' formed a linked list didn'y you?)
  30. The only thing to watch out for is that the window object under
  31. construction is sufficiently constructed to allow the other member functions
  32. to operate before doing anything that may call them. All the hidden book
  33. keeping is done before the programmer supplied body of a constructor.
  34. Now if you were calling virtual members of window whose definition was in a
  35. subclass of window this could be a whole different story.
  36.  
  37. If you want to post me the source (preferably in UUE over ARJ,ZIP,ZOO or LZH) 
  38. to look at that's OK but I can't promise anything.
  39. -- 
  40.     \\   ( )    No Bullshit!     |  Email: B.A.McCauley@bham.ac.uk   
  41.  .  _\\__[oo        from         |  Voice: +44 21 471 3789 (home)
  42. .__/  \\ /\@    /~)  /~[   /\/[  |    Fax: +44 21 625 2175 (work)
  43. .  l___\\      /~~) /~~[  /   [  |  Snail: 197 Harborne Lane,
  44.  # ll  l\\    ~~~~ ~   ~ ~    ~  |         Birmingham, B29 6SS, UK
  45. ###LL  LL\\   (Brian McCauley)   |   ICBM: 52.5N 1.9W
  46.