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