I'm learning C++ and now I'm working with Template.
I'm trying to implement a Linked List:
ListElement.hpp
#ifndef LIST_ELEMENT_HPP_
#define LIST_ELEMENT_HPP_
template <class Type> class SingleLinkedList;
template <class Type>
class ListElement
{
public:
ListElement(const Type element);
~ListElement(void);
public:
Type val;
ListElement* next;
};
#endif
ListElement.cpp:
#include "ListElement.hpp"
ListElement<Type>::ListElement(const Type element)
{
*next = NULL;
val = element;
}
ListElement<Type>::~ListElement(void)
{
}
I'm getting an Error on ListElement.cpp releated to Type
: Type is undefined
.
I have found a lot of examples about how to implement a Linked List but none using a separated hpp and cpp.
Do you know how can I fix this error?