one million dollar question
Hello out there! :)
I'm currently programming a linked list using C++ classes and I think I may need some advice. Here are my class declarations:
template <class TYPE>
class NODE {
protected:
NODE *create_node(T &item);
private:
TYPE info;
NODE *next;
};
template <class TYPE>
class LINKLIST : NODE<TYPE> {
public:
LINKLIST(void);
~LINKLIST(void);
void insert_node(TYPE &item, int nodal_pos);
void delete_node(TYPE &item, int nodal_pos);
TYPE retrieve_node(TYPE &item, int nodal_pos);
private:
NODE *head;
NODE *temp;
NODE *rover;
NODE *trailer;
int node_count;
};
Okay. Basically what is done here is to let NODE call itself recursively and create a NODE dynamically. insert_node() calls create_node() to do this and so on...
This style works properly when I implement it. But...
it looks somewhat awkward to me.
Now my one million dollar questio is:
Is there some other way to implement my list using only one class? or maybe two classes that looks better?
Hope you people can give me some advice :)
Thanks!
I have no idea what that means!?
*COUGH* CODE BLOCKS *COUGH*
;)