home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16652 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.5 KB  |  37 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!rational.com!thor!rmartin
  3. From: rmartin@thor.Rational.COM (Bob Martin)
  4. Subject: Re: Interobject member function calls while in construction
  5. Message-ID: <rmartin.722278411@thor>
  6. Sender: news@rational.com
  7. Organization: Rational
  8. References: <1509TB8w165w@rhps.chi.il.us>
  9. Date: Fri, 20 Nov 1992 16:53:31 GMT
  10. Lines: 25
  11.  
  12. warlok@rhps.chi.il.us (Jon L Fincher) writes:
  13.  
  14. |So, now the situation is this - I have a member function
  15. |screen::init() constructing a window.  window::window() calls other
  16. |owned member functions (not a problem, right?) and some functions
  17. |in screen (again, not a problem?). However, some member functions
  18. |in screen call window member functions, which has, at this time,
  19. |not finished instantiation.
  20.  
  21. There are two dangers inherent in this kind of situation.  First,
  22. Screen may be calling virtual function in Window.  Virtual deployment
  23. will not dispatch the function lower than the currently executing
  24. constructor.  Thus you may not get the function you expect.  Worse, if
  25. the virtual function is pure, the system will probably abort, since it
  26. is a fatal runtime error to call a pure virtual function.
  27.  
  28. So take care.  You may wish to create Window::init() functions which
  29. do all the initialization work after the window has been constructed.
  30.  
  31.  
  32. --
  33. Robert Martin                        Training courses offered in:
  34. R. C. M. Consulting                       Object Oriented Analysis
  35. 2080 Cranbrook Rd.                        Object Oriented Design
  36. Green Oaks, Il 60048 (708) 918-1004       C++
  37.