Re: C++ design question
From: H. S. Lahman (h.lahman_at_verizon.net)
Date: 09/29/04
- Next message: Ilja Preuß: "Re: XP Requirement Analysis?"
- Previous message: Universe: "Re: XP Requirement Analysis?"
- In reply to: kurth: "Re: C++ design question"
- Next in thread: kurth: "Re: C++ design question"
- Reply: kurth: "Re: C++ design question"
- Reply: Bob Hairgrove: "Re: C++ design question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Sep 2004 20:05:26 GMT
Responding to Kurth...
It was a nice explanation, but I was already aware of all that. [Or at
least I was a decade+ ago when I wrote my last C++. B-)]
> The initializers are called in the order they are declared rather then the
> order listed in the initialization list.
Which is a big part of the problem. There is a Catch-22 because
references must be in the initializer list but the constructor argument
itself may not be initialized when it is processed because of that
ordering. The problem here really highlights the difference between
instantiation and initialization, which is mostly hidden by the OOPL
syntax until one gets into an arcane situation like the OP's
self-referencing.
The OP's safety issue lay in initializing the reference object itself,
not the instantiation of the embedded reference. The solution is to use
the default constructor (which doesn't even have to be in the
initializer list) to do that instantiation while doing the actual
initialization of the reference object in the body via setters as I
suggested.
*************
There is nothing wrong with me that could
not be cured by a capful of Drano.
H. S. Lahman
hsl@pathfindermda.com
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
blog (under constr): http://pathfinderpeople.blogs.com/hslahman
(888)-OOA-PATH
- Next message: Ilja Preuß: "Re: XP Requirement Analysis?"
- Previous message: Universe: "Re: XP Requirement Analysis?"
- In reply to: kurth: "Re: C++ design question"
- Next in thread: kurth: "Re: C++ design question"
- Reply: kurth: "Re: C++ design question"
- Reply: Bob Hairgrove: "Re: C++ design question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|