don't know if this might help you, but how about using template classes? you'll only have to write that template once and then you can store whatever you want in it, in whatever project you want
could go somewhat like this:
Code: Select all
template <class T>
class Node {
private:
//ATTRIBUTES
//= following Node
Node<T>* next;
//= preceding Node. this will be NULL for the initial Node if chosing non-circular list
Node<T>* prev;
//= the actual data object
T* data;
public:
//FUNCTIONS
//constructors and destructors
//= Default constructor
Node() { data=NULL; next=NULL; prev=NULL; }
//=============================================================
// Default constructor. initialises the Node with the submitted data
// @param sData the data-containing object of the newly created Node
//=============================================================
Node(T* sData);
//= Default destructor.
~Node() {}
//accessing
//=============================================================
// sets the next-pointer to the Node that contains the next data-object
// @param sData the data-containing object to add to the list
//=============================================================
void SetNext(Node<T>* sNode) { next=sNode; }
//= returns the next Node in the list
Node<T>* GetNext() { return next; }
//=============================================================
// sets the prev-pointer to the Node that contains the previous data-object
// @param sData the data-containing object to add to the list
//=============================================================
void SetPrev(Node<T>* sNode) { prev=sNode; }
//= returns the previous Node in the list
Node<T>* GetPrev() { return prev; }
//= returns true if Node has a successor, false otherwise
bool HasNext() { return (next!=NULL ? true : false); }
//= returns true if Node has an antecedent, false otherwise
bool HasPrev() { return (prev!=NULL ? true : false); }
//= returns the data as pointer to the object used in this list
T* GetData() { return data; }
//processing
//=============================================================
// adds a new Node to the list
// @param sData the data to add
//=============================================================
void Add(T* sData);
//= deletes last node
void DeleteLast();
//= deletes the complete list after the calling Node
void DeleteList();
/* possibly more functions here */
};//template class
what you basically do here is just to implement a class that is managed like a linked list (that you could even configure to be circular).
to use this as a store you just declare:
Code: Select all
Node<Hero>* m_heroes=new Node<Hero>( /* your params here */);
that way you initialize the headNode with the first data object (there are far more complex structures possible, e.g. with different types of nodes, but this is just to show the idea...)
then you can manage your heroes as you want. basically it's only constructing nodes for the list, each one being able to store an arbitrary data object (int, bool, wxDialog, Hero etc.)
of course, you might be obliged to add custom functions, but here presented is only an example,
not fully functional code... (and, btw, it is not mandatory to use pointers...)