Greetings,
You might consider using the container classes of the Standard
Template Library? You'd then declare it like this:
#include <vector>
vector<clan_info> clan_array;
You can add elements by:
clan_array.push_back(some-clan-info);
You can get the array size by:
clan_array.size()
and adress elements with the operator[]
clan_array[x].somefield
I use the STL in my code pretty much and am pretty content with it.
Just a word of warning though: don't put pointers in STL containers,
but just real instances.
- Chris
> Ok, this is kinda CircleMUD related in that it has to do with
> how clans are currently done (i know clans aren't in CircleMUD).
>
> currently (the clan system I have I assume is some sort of snippet
> because a previous coder installed it), the clans
> are stored in a previously set array like so:
>
> struct clan_info clan[MAX_CLANS+1];
>
> well, I was thinking of instead of that, to just make it a class
> and still access it like an array.
> ie
> class clan_info;
> clan_info *clan;
>
> and in the class have something like an operator []
> clan_info* clan_info::operator[](int number) {
> int i=0;
> clan_info *cln;
>
> for (i=0, cln=this; cln && i != number; i++, cln = cln->next_clan) ;
> return (cln);
> }
>
> (i doubt the above would work but i hope the idea got through)
> so I could do something like this.
>
> clan[3].somekindainfo (or would it be clan[3]->somekindainfo?)
> and access it that way? still like an array?
> or would it be much less overhead
> just to zip through the entire linked list once, find the clan
> and return a pointer to it, and play with it from there?
>
> thanks for any insight into this.
>
> Code On
> Akuma the Raging Coder
>
> +------------------------------------------------------------+
> | "The poets talk about love, but what I talk about is DOOM, |
> | because in the end, DOOM is all that counts." - |
> | Alex Machine/George Stark/Stephen King, The Dark Half |
> | "Nothing is IMPOSSIBLE, Just IMPROBABLE" |
> | "Easier Said Than Done, But Better Done Than Said..." |
> +------------------------------------------------------------+
>
>
> +------------------------------------------------------------+
> | Ensure that you have read the CircleMUD Mailing List FAQ: |
> | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
> +------------------------------------------------------------+
>
--
/----------------------------------------------------------------------------\
| Christian Loth | Meet me as the >Shadowdancer< in the |
| chris@rom.mud.de | REALM OF MAGIC |
| http://privat.schlund.de/Loth | telnet rom.mud.de 4000 |
| | http://rom.mud.de/ |
| "The road goes ever on and on!" - Bilbo Baggins |
\----------------------------------------------------------------------------/
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST