Quote: "since our last conversation I implemented one of the ways we talked about and it worked fine! "
EXCELLENT!
You're having better luck than me currently. Ted6 is HOSED Alpha Dbo Export Doesn't work as advertised.
What you are saying reminds me of something IanM knows more about then me - only because (I admit it) I don't really "like" the idea even though I see its uses. This is Class Templates.
To my knowledge this allows you to make a "Pseudo class" that can be applied to multiple classes. In short - It "Writes the same code functionality" for different underlying data types. (I personally heard this and was like WOW - that IS SO AWESOME...(and I mean it still but...) but I'd never touch that with a ten foot pole!
)
I do something IanM says is closer to old School C - I don't totally agree - but I see his point - nad it has merit. (You need to know these things before I sugest design idea that might not be ideal
)
The important thing to know "low level" about classes, and inherited classes - (REAL inherited classes - not the dumbed down business example I gave which was more about "business structure" then proper ocde design for systems... but I digress... (They aren't mutually exclusive I must add though - business logic and proper "school" coding) anyway....
If you have a root class... The BEAUTY of object oriented code is that the variable members are created when you instantiate the class but the code exists once. ONCE!
If you "Override" and "Inherit" (c++ default I think), in C++ the Override is called first, then the original code is called. Like Wise, due to there design - They literally work like a pile of paper - neatly stacked. A book is a good example. If you original class has a variable named "MyAge", it is written at page one (remember using book as parable). If you inherit a million times, making a "Novel size" class. From a pointer point of view, An instance of your "Novel Class" STILL has that same "MyAge" variable on page 1... or:
// not real values - but to prove a point
TORIGINALCALSS *Daddy=NEW TORIGINALCLASS();
Then mem address pointed to by "Daddy" PLUS Page 1 = Address of MyAge Variable for that instance.
TCHILDOFORIGINAL *ChildClass = NEW TCHILDOFORIGINAL();
Then mem address pointed to by "ChildClass" PLUS Page 1 = Address of MyAge Variable for that instance also!
The point is - I personally use linked lists (You could make your own or learn STDLIB ones) .. I made my own - silly - but I know it intimately.
Anyways - My BASE classes all have "BASE" variables needed so I can store "Lists" of them (that work like a database, "MoveFirst, MoveNext, Append, Insert etc.) And regardless of what I put in the child classes, plants or trees, I can maintain my list the same way. To access the members of "TREE" class though - I TypeCast the void pointer in my "Linked List" that is pointing to the current "Item" we are working on.
Also - for speed sake, I save "BookMarks" in my linked list because sometimes - for reasons of either convienance and raw CPU speed - I'll directly reference an "Item" Via the saved "BookMArk pointer" versus using the Linked list to navigate to it. This does make for some ugly type casts - but lightning code - if not dereferencing to deep when you try to get fancy.
There are STDLIB "Lists" and "Dynamic array" that are well tested, use templates as mentioned above - and allow the same functyionality - possibly more readable - defaintely more industry standard - but then again - Microsoft makes many industry standards and they aren't always a good thing - but usually pretty trustworthy
This allows throwing forrest and tree objects in same list.
One thing I do if I decide I must mix dirreferent "Classes" in same list (I usually don't do that) You proably would add a variable to the ITEM base class that you build on that has some sort of "TYPE" # in it so you only perform execute code for a given class when you know your pointer is defiantely pointing to the class you want.
TRUE Hierarchy's - that are of a dynamic nature tend to be a sginle list of items - with references to itself - - this translates to a "ParentID", where ParentID=0 is the ROOT or top directory. then you have however many kinds of data stored in a "DIR" but then you have special entries that are indeed "DIR" references which point to a "Sub Root"... and it takes recursive routines to properly read the whole heirarchy without missing a beat. This kind of code is not overly complex but can get dicey trying to debug because as you stare at the code you have to think how its calling itself, and how many levels deep you are, and what the variable are "NOW" and if you call yourself again, or exit - how will i be.. etc. when its working - Its awesome - getting it working - sometimes can be a long stare at your screen - complete silence - no keys being pressed - then finally you see the flaw - AAHHH HA!!! click click click...
Note - all this typing is because you said "Lists". there is a lot to be said for what you can do with straight inheritance if alot of the functionality between forrest, trees, plants are the same in your application. If not... Well.. you always can simplyfy by just having three lists or something versus trying to force them into one. (This is what I typically do)
I'll have a list of ALL OBJECTS.
A list if "TRees" (Stores bookmarks to ALL-OBJECTS LIST)
A list of "Plants" (Stores bookmarks to ALL-OBJECTS LIST)
this way I can loop through EVERYTHING, Or just plants, or just trees. the rule I follow is the MAIN "OBJECT" (DarkGDK Class I wrote generic) is the master of the ACTUAL OBJECTS.
In this example, My Tree list "ITEM CLASS" would have all my TREE methods, variables as well as a pointer to the ALL-OBJECTS LIST for the tree in question.
I could do this various ways - Like make it totally wrapped - so its as easy as "Delete Tree" and it cascades and does all - but I don't like being that rigid in a game. I might Want to remove a tree from the tree list, but not kill the object in DarkGDK... Why? Let's say tree got chopped down and is falling into a river... now it isn't a tree - is my FloatingLog "Thing" I have a separate class for. See?
There are many ways to skin a cat - I hope I tossed some ideas at least your way!
If this all sounded like nonsense I apoligize
Good Luck!