I am attempting to write a doubly linked list with abstract data types to store class objects from files passed to the program as command line arguments. At the present point, I am simply trying to get the linked list to work with anything so it's currently a singly linked list. Much of the other parts of the program present are just for testing things little by little.
Everything compiles and runs correctly, which I tested every time I made a change, but then when I tried to actually use the linked list things started to break. Currently, I am trying to just have it hold an integer as the first step and then when it works I will try to get it to hold objects.
Using either of these declarations work to create a list object:
sleepRecordList<typedef> list;
or
sleepRecordList<int> list;
However, when I try to insert an integer into the list like so:
list.insertLast(1);
I get this error:
Error LNK2019 unresolved external symbol "public: void __thiscall sleepRecordList<int>::insertLast(int const &)" (?insertLast@?$sleepRecordList@H@@QAEXABH@Z) referenced in function _main
Error LNK1120 1 unresolved externals
To me, it sounds like a mismatch between the header and the .cpp file, but I didn't see a problem there so then I removed const from it and got this error instead:
Error C2244 'sleepRecordList<Type>::insertLast': unable to match function definition to an existing declaration
Here's what the method looks like that I am trying to access:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
template<class Type>
void sleepRecordList<Type>::insertLast(const Type & item)
{
Node<Type> *newNode;
newNode = new Node<Type>;
newNode->data = item;
newNode->link = nullptr;
if (first == nullptr)
{
first = newNode;
last = newNode;
count++;
}
else
{
last->link = newNode;
last = newNode;
}
}
|
In my program I am not using namespace std; instead I am using each part of the namespace as I need it, but in the off-chance I missed something I added using namespace std; and then I got these errors instead:
Error C2872 'end': ambiguous symbol
Each time I tried using that object, which incidentally worked fine before adding the entire namespace and the old error comes back when removing them so I am fairly certain now that I'm not missing something simply like that.
Now, I expect that someone would want to see more than this, and I'm not sure just how much will be needed, so the following is the entire program typed out with file name labels:
(will have to put it in a reply, because of max characters)