Я думаю, что это просто проблема синтаксиса. Но независимо от того, как я это делаю, я продолжаю получать ошибки компилятора. Я использую класс списка на основе Node и не могу понять, как записать заголовок объявления. Где я могу разместить объявление класса вперед и т.д.? Я просто не знаю, как это сделать. Ниже приведен весь заголовок объявления:
#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;
};
Измените его на
template <class T>
class List
и добавьте тип T к объявлениям узлов
Node<T>* head;
Node<T>* cursor;
'ostream' does not name a type.
Как мне решить это?
std::ostream
либо добавьте, using std::ostream;
после того, как вы #include <ostream>