Hi The program given below runs well does the required but prints on output screen Null pointer assignment while exiting from main ......
Please help me to debug the program.......... Just to mention it is only a part of program pasted to make things simple to understand and bug lies here since this part of the program when compiled and run prints on screen Null pointer assignment.... else does well

I am using Turbo C++ version 3.0 compiler

Code:
#include<iostream.h>
#include<process.h>
#include<stdio.h>
struct list
       {int data;
    list *next;
    list *previous;
       };


class integer
{
  char *p;

  list *head;

public:
   integer()
       {head=NULL;
       p=NULL;
       }
   ~integer()
    {list *tmp=head;
     while(tmp!=NULL)
          {tmp=tmp->next;
           delete(tmp->previous);
           }
     head=tmp;
     delete(p);

     }

friend ostream& operator <<(ostream &, integer &);
friend istream& operator >>(istream &,integer &);
integer& operator +(integer&);

};

ostream& operator << (ostream& o,integer& x)
   { list *tmp=x.head;

     if(tmp==NULL)
     { o<<"Integer Has Not Been Assigned Any Value"<<endl;
       return o;
     }

     while(tmp!=NULL)
     { o<<tmp->data;
       tmp=tmp->next;
      }

     return o;

  }

istream& operator >> (istream& i,integer& x)
       {list *tmp=x.head;
    char *k=NULL;
     i>>x.p;
     k=x.p;
     if(tmp!=NULL)
    { while(tmp->next!=NULL)
     tmp=tmp->next;
     while(tmp->previous!=NULL)
     {tmp=tmp->previous;
      delete(tmp->next);
     }
     delete(x.head);
    x.head=NULL;
     }
    while(*k!='\0')
         {if(x.head==NULL)
         {
         tmp=new(list);
         if(tmp==NULL)
         {cout<<"No Memory For Allocation"<<endl;
         exit(0);
         }
         tmp->previous=NULL;
         tmp->next=NULL;
          x.head=tmp;
          tmp->data=*k - 48;
         k++;
          }
         else
         {
           tmp->next=new(list);
        if(tmp==NULL)
         {cout<<"No Memory For Allocation"<<endl;
         exit(0);
         }
           tmp->next->previous=tmp;
           tmp=tmp->next;
           tmp->next=NULL;
           tmp->data=*k - 48;
           k++;
         }
         }
 return i;


}

void main(void)
{integer k;
cin>>k;
cout<<k;

}