|
Posted by Peter Fox on 12/30/05 12:19
Following on from Lüpher Cypher's message. . .
>Hi,
>
>Suppose we have a hierarchical class structure that looks something like
>this:
Sorry, I lost the plot half way through.
Your objects can be
1 - nesting : object has a 'what are my children' and 'who is my
parent' functionality.
2 - pointing : eg object has a 'these are my siblings' or
'previous/next' functionality
3 - dictionary entries : object in some container is discoverable by
name
Variations and combinations of course apply. BUT every object exists in
some context. I /think/ you might be trying to get A's to point-to/own
B's where more than one A could be the parent of a B. Eg
"Sally is daughter of Jean"
"Geoffrey is son of Teddy"
"Sally is daughter of Teddy" // Only one Sally! J+T are married.
In this case[1] create an array of children and point to elements in
that array from your parent objects.
eg $child['Sally'] = new ChildObj(.....);
then $Jean->AddChild('Sally') // just a key name or index
or $Jean->AddChild($child['Sally']) // inside the routine do $myKids[]
= & $NewChild
where $NewChild is the function argument.
[1] If in this example children can be parents then you should be
looking at a single universal 'person' class with the necessary links.
--
PETER FOX Not the same since the adhesive company came unstuck
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Navigation:
[Reply to this message]
|