This is my header file for a linked list class. When I try to compile it says an internal error has occurred. What is wrong with my code.
Code:
#pragma once
#ifndef LINKED_LIST
#define LINKED_LIST
#include <iostream>
#include <vector>
#define LINKS 1
template <class T> struct SingleLinkedNode;
template <class T> struct DoubleLinkedNode;
#if !defined(LINKS) || LINKS == 1
template <class T, class U = SingleLinkedNode<T>>
class LinkedList {
#elif LINKS == 2
template <class T, class U = DoubleLinkedNode<T>>
class LinkedList {
#else
#error implement me
#endif // LINKS
public:
struct SingleLinkedNode {
SingleLinkedNode *next = nullptr;
T data;
};
struct DoubleLinkedNode {
DoubleLinkedNode *previous = nullptr;
DoubleLinkedNode *next = nullptr;
T data;
};
#ifndef NODE
#define NODE
#if !defined(LINKS) || LINKS == 1
struct Node : public SingleLinkedNode;
#elif LINKS == 2
struct Node : public DoubleLinkedNode;
#else
#error implement me
#endif // LINKS
#endif // NODE
LinkedList();
LinkedList(U *firstPtr);
LinkedList(T *ptr, const size_t& elements = 1);
LinkedList(const std::vector<T>& vectorRef);
template <size_t N> LinkedList(T arrayPtr[N]);
LinkedList(const LinkedList<T>& listRef);
~LinkedList();
U* first();
U* last();
U* at(const size_t& index);
U* del(const size_t& index);
void clear();
void set(U *firstPtr);
void set(T *ptr, const size_t& elements);
void set(const std::vector<T>& vectorRef);
template <size_t N> void set(T arrayPtr[N]);
void set(LinkedList<T> list);
void replace(const T& oldValue, const T& newValue);
void remove(const T& value);
void reverse();
void insertFront(const T& value);
void insertBack(const T& value);
void insert(const size_t& index, const T& value);
int countOf(const T& value);
bool contains(const T& value);
bool isEmpty();
T* data();
std::vector<T> data();
size_t length();
size_t size();
bool operator == (LinkedList<T> list);
LinkedList& operator = (LinkedList<T> list);
T& operator [] (const size_t& index);
private:
U *firstNode;
};
#endif // LINKED_LIST