What to check for when given 'unresolved externals' error
Nov 3, 2013 at 10:14pm UTC
(note: the following CPP file uses a header file provided by the professor that makes the item and node items private members of a Node Class and uses member functions ->getItem(),->getNext(), ->setItem(), and ->setNext() to access them. I didn't want to post the header file in its entirety because I felt it was too much code for one question).
I've been getting unresolved external errors for this CPP file and personally I do not understand what to even look for as everything looks OK to me. I'd like some help in determining what the issue is and what I should generally check when I receive this error in the future.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
//LinkedSortedList.h File
#ifndef _LINKEDSORTED_LIST
#define _LINKEDSORTED_LIST
#include"Node.h"
template <class ItemType>
class LinkedSortedList
{
private :
Node<ItemType> *head;
int itemCount; //Current count of list items
//Node<ItemType> *getNodeBefore(const ItemType &anEntry)const;
Node<ItemType> *getNodeAt(int position) const ;
public :
LinkedSortedList(); //Default constructor
LinkedSortedList(const LinkedSortedList<ItemType> &aList); //Copy constructor
bool isEmpty() const ;
int getLength() const ;
bool remove(int position);
void clear(); //remove all the items from the list
ItemType getEntry(int position) const ;
void displayList();
/*Following are three new methods:
void insertSorted(const ItemType &newEntry);
bool removeSorted(const ItemType &anEntry);
int getPosition(const ItemType &newEntry)const;*/
};
template <class ItemType>
LinkedSortedList<ItemType>::LinkedSortedList (){
head=NULL;
itemCount=0;
}
template <class ItemType>
LinkedSortedList<ItemType>::LinkedSortedList(const LinkedSortedList<ItemType> &aList){
head=aList;
itemCount=0;
Node<ItemType> *findItemCount=head;
(while findItemCount!=NULL){
findItemCount=findItemCount->getNext();
itemCount++;
}
}
template <class ItemType>
Node<ItemType> *LinkedSortedList<ItemType>::getNodeAt(int position) const {
if (position<0 || position>itemCount){
cout<<"Invalid position! Program aborted!\n" ;
exit(1);
}
Node<ItemType> *nodePtr=head;
for (int i=1;i<position;i++)
nodePtr=nodePtr->getNext();
return nodePtr;
}
template <class ItemType>
bool LinkedSortedList<ItemType>::isEmpty() const {
return itemCount==0;
}
template <class ItemType>
int LinkedSortedList<ItemType>::getLength() const {
return itemCount;
}
template <class ItemType>
bool LinkedSortedList<ItemType>::remove(int position) {
bool ableToRemove=(position>=1) && (position<=itemCount)
if (ableToRemove){
Node<ItemType> *nodePtr=head;
if (position==1){
nodePtr=nodePtr->getNext();
head=nodePtr;
} else if (position==itemCount) {
nodePtr=getNodeAt(position-1);
deletePtr=nodePtr->getNext();
nodePtr->setNext(NULL);
deletePtr=NULL;
delete deletePtr;
} else {
nodePtr=getNodeAt(position-1);
Node<ItemType>* deletePtr = nodePtr->getNext();
nodePtr->setNext(deletePtr->getNext());
deletePtr=NULL;
delete deletePtr;
}
return ableToRemove;
}
template <class ItemType>
void LinkedSortedList<ItemType>::clear(){
itemCount=0;
}
template <class ItemType>
ItemType LinkedSortedList<ItemType>::getEntry(int position) const {
bool ableToGet=(position>=1) && (position<=itemCount);
if (ableToGet){
Node<ItemType> *nodePtr=getNodeAt(position);
return nodePtr->getItem();
}
else
throw logic_error("You tried to getEntry().....BUT FAILED" );
}
}
template <class ItemType>
void LinkedSortedList<ItemType>::displayList(){
for (int i=0; i<itemCount; i++)
cout<<getEntry(i+1)<<endl;
}
#endif
.
Nov 3, 2013 at 11:50pm UTC
Topic archived. No new replies allowed.