Reputation: 1565
I think this is simply an issue of syntax. But no matter how I do this I keep getting compiler errors. I'm using a Node-based list class and can't figure out how to write the declaration header. Where do I place the forward List class declaration, etc? I just don't know how to set this up. Below is the entire declaration header:
#include <iostream>
using namespace std;
class List;
template <typename T>
class Node{
private:
Node(T, Node*);
T data;
Node* next;
friend class List<T>;
friend ostream& operator<<(ostream&, const List<T>&);
};
class List{
public:
List(int = 0);
List(const List&);
~List();
bool gotoBeginning();
bool gotoEnd();
bool gotoNext();
bool gotoPrior();
bool insertAfter(T);
bool insertBefore(T);
bool remove(T&);
bool replace(T);
bool getCursor(T&) const;
bool empty() const;
bool full() const;
bool clear();
List<T>& operator=(const List&);
friend ostream& operator<<(ostream&, const List<T>&);
bool operator==(const List&) const;
private:
Node* head;
Node* cursor;
};
Upvotes: 0
Views: 84
Reputation:
Change it to
template <class T>
class List
and add the T type to the nodes declarations
Node<T>* head;
Node<T>* cursor;
Upvotes: 1