linked list help please.

From: fighterman (fighterman_at_u.net)
Date: 03/31/04


Date: Tue, 30 Mar 2004 22:26:06 -0600

I have a class

template <typename T>
class node
{
public:
        T nodevalue; //store value
        node<T> *next;

        node(){next=NULL;}
        

        node( T value, node<T> * ptr = NULL): nodevalue(value),next(ptr)
        {}

        
};

this is insertrear function to insert node at the back of the linked list

template <typename T>
void insertrear( T value, node<T> * ptr)
{
        node<T> *curr = *ptr;
        node<T> * temp= new node<T>(value);

      if(curr=NULL)
          {
                  
                  temp->next=curr;
           curr=temp;

          }
          else{
                while(curr->next!=NULL)
                {

                        curr=curr->next;
                }

                temp->next=curr->next;
                curr->next=temp;
          }
                
delete temp;
}

And in the main function

int main()
{
node<int> *head;
for (int i=9; i>=0; i--)
insertrear( i , head);

return 0;
}

the problem is why when i run it, there is an pop up window said debug
error, run time check #3, head is using without defined.

I think when I declare head it will call the default constructor which is
next = NULL

what am I doing wrong?