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