Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

original vesoljc

linked list template again....

This topic is 5777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

why something like this won''t work??? template class Node { public: T m_data; char* m_ident; UINT m_index; Node* m_next; Node* m_prev; }; [ class Data_List { private: Node* m_head; UINT m_num_items; public: Data_List (); virtual ~Data_List (); bool AddNode(templateNode in, char* ident); }; // implementation Data_List::Data_List() { } Data_List::~Data_List() { } ] right way to do it?!? Abnormal behavior of abnormal brain makes me normal...

Share this post


Link to post
Share on other sites
Advertisement
template
class List
{
private:
struct node
{
T *element;
node *next,*prev;
} *first;
int m_num_items;
public:
List();
void add(T*);
~List();
};

//implementation
template
List::List()
{
first=NULL;
m_num_items=0;
}

template
void List::add( T *e )
{ //add at the begining
nodo *n=new node;
n->next = first;
if(first)
n->prev = NULL;
n->element = e;
first = n;
m_num_items++;
}

template
List::~List()
{
...
}

this is the way that i use it, and it work. you must put all in the .h file, another way you would need some compiler directives.
to define a list:
List list_of_int;

i hope you can understand my english and i hope this help you.

good luck.

naher

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!