title: C++ Doubly Linked List Program
body: <p>I've been trying to teach myself programming for a few months now, I've bought about three books and watched a tonne of videos on YouTube which has been great so far. But the last week or so I've been stumped thanks to linked lists! I get the whole concept but the syntax is killing me! I've written a few very simple linked lists programs for exercise but now I'm trying to write a program where I load in some information from a file (information of people who have applied for a visa) onto a linked a list then just display the whole lot again(once that is done I plan on expanding it to where I only display certain nodes and remove certain nodes but I wont go into detail). Hopefully the code shown below is not too lengthy and if I could just get some pointers (no pun intended) or some snippets to help me understand this stuff that would be awesome!</p>
  
  <p>p.s some of this code is from a similar example in a book. </p>
  
  <p>here is the main(most of it)with the loop to load the information(it doesn't work)</p>
  
  <pre><code> List myList;
   visa_application *visa;
  
   Node * pNode;
  
   string visa_type;//these are all the variables that i want to load from the file
   int invoice_no;
   string surname;
   string firstname;
   double contact;
   string status;
   string result; 
  
  ifstream in;
  in.open("applications.txt",ios::in);
  
  
  
        while (!in.eof()){     
           pNode = new Node;
           visa = new visa_application;    //allocate memory for nodes
  
           in &gt;&gt; visa-&gt; visa_type &gt;&gt; visa-&gt;invoice_no &gt;&gt;  visa-&gt; surname;
           in &gt;&gt; visa-&gt; firstname &gt;&gt; visa-&gt; contact &gt;&gt; visa-&gt; status &gt;&gt;  visa-&gt; result ; 
  
           pNode-&gt;nData = &amp;visa;   //put some data in the node
           myList.appendNode(pNode); //add node to list
  
           }
  </code></pre>
  
  <p>Here is my class node header file</p>
  
  <pre><code> class Node
  {
        friend class List;
        private:
                node_data * nData;
                Node *pNext;
                Node *pPrev;
        public:
                Node  (node_data * data){nData = data;
                                      pNext = NULL;
                                     pPrev = NULL;}
               node_data * getData(){return nData;}
  };
  </code></pre>
  
  <p>here is class list header file</p>
  
  <pre><code>class List
  {
      private:
          Node *pHead;
          Node *pTail;
          Node  *createNode(node_data * data);
      public:
          List ();
          ~List();
          Node  *getpHead (){ return pHead;}
          Node  *getpTail (){return pTail;}
          Node  *previousNode(Node  *pNode){return pNode-&gt;pPrev;}
          Node  *nextNode (Node  *pNode){return pNode-&gt;pNext;}
          void appendNode(node_data * value);
          void insertNode(node_data * value, Node  *pAfter);
          void removeNode(Node  *pNode);
          bool isEmpty();
          void printList(); 
  };
  
  List ::List() {
      pHead=NULL;
      pTail=NULL;
  }
  
  List ::~List(){
      while (!isEmpty())   //keep on removing until the
                                 //head points to NULL
          removeNode(pHead);
      cout &lt;&lt; "List deleted\n";
  }
  
     Node * List::createNode(node_data * data){
     Node * pNode = new Node (data); //allocate memory for new node and
                                   //intialize value to data
     return pNode;  
  }
  
     bool List ::isEmpty(){
     return pHead == NULL;
  }
  
  void List ::appendNode(node_data * value)
  {
     Node * pNode = createNode(value);
  
     if (isEmpty()) {     //if list is empty
          pHead = pNode;        //make head point to pNode
          pNode-&gt;pPrev = NULL;
     }
     else {                    //otherwise
          pTail-&gt;pNext = pNode;  //make tail point to pNode
          pNode-&gt;pPrev = pTail;
     }
     pTail = pNode;        //tail is now pNode
     pNode-&gt;pNext = NULL;  //pNode next now points to NULL
  }
  
  
  void List ::insertNode(node_data * value, Node  *pAfter)
  {
     Node *pNode =  createNode(value);
     pNode-&gt;pNext = pAfter-&gt;pNext;
     pNode-&gt;pPrev = pAfter;
  
     if (pAfter-&gt;pNext != NULL)
          pAfter-&gt;pNext-&gt;pPrev = pNode;
     else
          pTail = pNode;
     pAfter-&gt;pNext = pNode;
  }
  
  void List ::removeNode(Node  *pNode)
  {
     if (pNode-&gt;pPrev == NULL)  //if removing the head
          pHead = pNode-&gt;pNext;
  
     else
          pNode-&gt;pPrev-&gt;pNext = pNode-&gt;pNext;  //if removing a middle node
  
     if (pNode-&gt;pNext == NULL)  //if removing the tail
          pTail = pNode-&gt;pPrev;
  
     else
          pNode-&gt;pNext-&gt;pPrev = pNode-&gt;pPrev;
     pNode = NULL;
     delete pNode;  //*free the memory
  }
  
  void List ::printList()
  {
     Node  *pNode=pHead;
     if (isEmpty())
          cout &lt;&lt; "The list is empty\n";
     else
          for (pNode = pHead; pNode != NULL; pNode = pNode-&gt;pNext)
              pNode-&gt;nData-&gt;print();
  }
  </code></pre>
  
  <p>My class visa application header file  </p>
  
  <pre><code>class visa_application
  {
  public:
      // class constructor
      visa_application();
      // class destructor
      ~visa_application();
  
  
  
  private:
       string visa_type;
       int invoice_no;
       string surname;
       string firstname;
       double contact;
       string status;
       string result;     
  };
  </code></pre>
  
  <p>and finally the visa application.cpp</p>
  
  <pre><code>     visa_application::visa_application()
  {
       string visa_type = none;
           int invoice_no = 0;
           string surname = none;
           string firstname = none;
           double contact = 00;
           string status = none;
           string result = none; 
   }
  
   class destructor
   visa_application::~visa_application()
  {
  // insert your code here
  }  
  </code></pre>
  
  <p>I'm getting the error "no matching function for call to `List::appendNode(Node*&amp;)'" among a few other things.Anyway I know this is long but it would be great if i could get some help, I do not have a tutor or teacher or someone like that to help me so any feedback would be much appreciated! Thanks! </p>
  
  <p>**EDIT the error messages are:</p>
  
  <pre><code> no matching function for call to `Node::Node()' 
   candidates are: Node::Node(const Node&amp;) 
   Node::Node(node_data*)     
   no matching function for call to `List::appendNode(Node*&amp;)' 
   candidates are: void List::appendNode(node_data*)   
  </code></pre>