I'm a relatively new programmer I'm working on a templated linked list project that can take in multiple linked lists of different data types. I think I've almost got it to work but there is an error that keeps coming up saying that my identifier "m_node" is unidentified. I've researched the error and have found solutions that either aren't relevant to what I'm doing or I've already done, like including the header file for Node in TemplinkedList.h specifically, leaving me thoroughly confused. Here is my TempLinkedList.cpp and Node.h files, apologies if the answer is obvious and thank you in advance if you can crack it.
Edit: Thank you all for your suggestions. I've tried them all out and have managed to resolve the issue. Another error has come up though. This one is called LNK2019 and it says that there is an unresolved external symbol, I assume in my Source.cpp file since it refers to the void main() function. I've tried to fix it but I'm not sure which part of the function is throwing the error.
Source.cpp:
#include "Node.h"
#include "TempLinkedList.h"
template<typename T>
void Testone()
{
TempLinkedList* list = new TempLinkedList();
TempNode* m_head1 = new TempNode("2");
TempNode* m_head2 = new TempNode("4");
TempNode* m_head3 = new TempNode("6");
TempNode* m_head4 = new TempNode("8");
TempNode* m_head5 = new TempNode("10");
TempNode* m_head6 = new TempNode("12");
list->PushBack(m_head1);
list->PushBack(m_head2);
list->PushBack(m_head3);
list->PushBack(m_head4);
list->PushBack(m_head5);
list->PushBack(m_head6);
list->Execute();
}
template<typename T>
void main(T TTempNode)
{
Testone<T>();
TempNode<T> TTempNode;
T numAdd = TTempNode.GetNext();
system("pause");
}
TempLinkedList.cpp:
#include <iostream>
template<typename T>
TempLinkedList<T>::TempLinkedList()
{
m_head = nullptr;
}
template<typename T>
T TempLinkedList<T>::GetHead()
{
return nullptr;
}
template<typename T>
void TempLinkedList<T>::PushBack(T data)
{
TempNode* temp = m_head;
if (m_head == nullptr)
{
m_head = m_node; // error point
return;
}
while (temp->GetNext() != nullptr)
{
temp = temp->GetNext();
}
temp->SetNext(m_node); // error point
}
template<typename T>
void TempLinkedList<T>::Execute()
{
TempNode* temp = m_head;
while (temp != nullptr)
{
temp->Execute();
temp = temp->GetNext();
}
}
Node.h:
#include <string>
#include <iostream>
using namespace std;
template<typename T>
class TempNode
{
public:
TempNode(string* data, int* m_node)
{
m_node = new T[];
data = new T[];
}
TempNode(T data, T next, T m_node);
~TempNode();
void SetNext(T* next);
T* GetNext();
T GetData();
void execute();
private:
T* data;
T* next;
T* m_node;
};