Computer Science Canada Parent->Children->Children (Pointers) |
Author: | Flikerator [ Mon Feb 26, 2007 5:03 pm ] | ||
Post subject: | Parent->Children->Children (Pointers) | ||
I remember pointers a tad (Currently reading the Pointer tutorial) but while I do that I thought I would throw this out here in case I'm on the wrong path. Basically what I'm trying to do is form a list. I have a list of names and each name has a list of its children and they all have a list of their children and so on. I was considering doing something like;
So each child can have children (1000 for now, thats the limit of children. Although a flexible array could work, I thought I would work on POINTERS first and then work on that later). So you have the Root and it stores that roots name, along with an array of its children that can all have children. Reading through the tutorial I might use ID's to identify parents or whatever, but for now just wondering if this could work? I've never used pointers before (to any real extent, I've copy and pasted and messed around a bit). If you've done something like this and have any helpful tips I'd appreciate it. |
Author: | Flikerator [ Mon Feb 26, 2007 6:25 pm ] | ||
Post subject: | Re: Parent->Children->Children (Pointers) | ||
Alright so I've been working on it a bit, and I don't know if I'm close or waaaaaaaaaaaay off.
The top was me just messing around. The bottom is what I'm working on. So it creates the main head person and names him child with NO children. BAM he has a child, so we create a new child. His child is given the name Stanley. The process could be repeated, but just for one more child it gets long (and confusing). There is probably an easier/possible way to do it. Im still working on it, let me know if you can help. |