0

I am experimenting with linked classes but i am having trouble finding an error in my code, the error that is given to me is Error

" error LNK2019: unresolved external symbol "public: __thiscall NumberList::~NumberList(void)" (??1NumberList@@QAE@XZ) referenced in function _main D:\Fall 2014\C++ ADV\C++ ADV\Driver Program.obj "

however i am looking at my driver program and i see that i am calling my linked class correctly and i don't understand how it is giving me an unresolved external error. If some one see's something that i am not not looking at please let me know.

**NumberList.h**

// Specification file for the NumberList class
#ifndef NUMBERLIST_H
#define NUMBERLIST_H

class NumberList
{
private:
  // Declare a structure for the list
  struct ListNode
 {
    double value;           // The value in this node
    struct ListNode *next;  // To point to the next node
 }; 

 ListNode *head;            // List head pointer

public:
 // Constructor
 NumberList()
    { head = NULL; }

 // Destructor
 ~NumberList();

 // Linked list operations
 void appendNode(double);
 void insertNode(double);
 void deleteNode(double);
 void displayList() const;
};
#endif


**NumberList.cpp**

        #include <iostream>
        #include "NumberList.h"
        using namespace std;

        void NumberList::appendNode(double num)
        {
            ListNode *newNode;  // To point to a new node
            ListNode *nodePtr;  // To move through the list 16     // Allocate a new node and store num there.
            newNode = new ListNode;
            newNode->value = num;
            newNode->next = NULL;

             // If there are no nodes in the list
             // make newNode the first node.
             if (!head)
                head = newNode;

            else  // Otherwise, insert newNode at end.
            {
                // Initialize nodePtr to head of list.
                nodePtr = head;

                // Find the last node in the list.
                while (nodePtr->next)
                nodePtr = nodePtr->next;

                // Insert newNode as the last node.
                nodePtr->next = newNode;
            }
        }

    void NumberList::displayList() const
    {
        ListNode *nodePtr;  // To move through the list

        // Position nodePtr at the head of the list.
        nodePtr = head;
        // While nodePtr points to a node, traverse
        // the list.
        while (nodePtr)
        {
            // Display the value in this node.
            cout << nodePtr->value << endl;
            // Move to the next node.
            nodePtr = nodePtr->next;
        }
    }


**Driver Program.cpp**// This is just to test out my list class

 // This program demonstrates the displayList member function.
      #include <iostream>
     #include "NumberList.h"
     using namespace std;
    int main()
    {
        // Define a NumberList object.
        NumberList list;
        // Append some values to the list.
         list.appendNode(2.5);
        list.appendNode(7.9);
        list.appendNode(12.6);
        // Display the values in the list.
        list.displayList();
         return 0;
    }
EasyE
  • 560
  • 5
  • 26

0 Answers0