I'm trying to create a linked list, but when I run IsEmpty(test) it just says it was not declared in this scope even though it's public.
I'm pretty new at templates, but I couldn't find the answer on google so I have to ask here. Anyone know what the problem is?
Also, the error points to main() where I call IsEmpty()
//.h
template <typename ItemType>
class Node
{
public:
ItemType Data;
Node <ItemType> *next;
int position;
};
template <typename ItemType>
class Linked_List
{
public:
Node <ItemType> *start;
Linked_List();
bool IsEmpty();
}
//.cpp
#include "Linked_List.h"
#include <iostream>
#include <cstdlib>
using namespace std;
template <typename ItemType>
Linked_List <ItemType>::Linked_List(){
start = NULL;
}
template <typename ItemType>
bool Linked_List <ItemType>::IsEmpty(){
if (start == NULL){
return true;
}
return false;
}
int main(){
Linked_List <int> test;
cout << IsEmpty(test) << endl; //error points to here
}