Hey, Im programming a linkedlist that works with a Structure and class, for some reason I get this error.
error C2955: 'SNode' : use of class template requires template argument list
What exactly is a Template Arguement List? Here is my code.
#pragma once
#include <iostream>
using namespace std;
template <typename T>
struct SNode
{
T m_iData;
SNode* m_pNext;
};
template <typename T>
class CLinkList
{
public:
CLinkList<T>() : m_pHead(0) {};
void AddNode(T iData);
void Display();
private:
SNode* m_pHead;
};
template <typename T>
void CLinkList<T>::AddNode(T iData)
{
SNode* pNew = new SNode;
pNew->m_iData = iData;
pNew->m_pNext = m_pHead;
m_pHead = pNew;
}
template <typename T>
void CLinkList<T>::Display()
{
SNode* pCurrent = m_pHead;
while(pCurrent)
{
cout << pCurrent->m_iData << endl;
pCurrent = pCurrent->m_pNext;
}
}
And main
#include "LinkList.h"
int main()
{
CLinkList <int> I;
I.AddNode(5);
I.AddNode(2);
I.AddNode(3);
I.Display();
//try more data types here!!
return 0;
}
~~Johnathan~~LTM my new fad, know it, use it, love it, LAUGHING TO MYSELF