当List.cc:19:1: error: âIteratorâ does not name a type
. 标题如下
class List {
private:
class Element {
public:
char data;
Element *next;
Element *prev;
Element(Element *n,Element *p, char d);
};
Element *first;
public:
class Iterator {
public:
Iterator();
void operator++();
void operator--();
char& operator*();
const char& operator*() const;
bool operator==(const Iterator& itr);
bool operator!=(const Iterator& itr);
private:
Iterator(const Element& ele);
Iterator *it;
};
List();
~List();
Iterator& begin() const;
Iterator& end() const;
void insert(Iterator itr, char c);
void erase(Iterator itr);
};
第 19 行是:
Iterator& List::begin() const
这是继承问题吗?我试图在主函数中调用迭代器,就像通过 List::Iterator 调用 std::list