I am trying to create a Map structure, but am having a problem with declaring the iterator for the class. Here is my class declaration:
#ifndef MAP_H
#define MAP_H
#include "Set.h"
#include "Pair.h"
using namespace std;
template <class Key, class Value>
class Map : public Set< Pair<Key, Value> >
{
public:
typedef Pair<Key, Value> value_type;
typedef Set< value_type > parent;
typedef parent::iterator iterator;
Map() : parent() {}
Map(Map<Key, Value> & m) : parent(m) {}
Value & operator [] (Key&);
void erase(Key&);
void erase(iterator& itr) {parent::erase(itr);}
iterator find(Key&) const;
protected:
iterator map_insert(value_type & x)
{
parent::insert(x);
return parent::find(x);
}
};
It is complaining about the line: "typedef parent::iterator iterator;"
I don't see a problem with this since the type is declared by the typedef parent. I would appreciate any insight into this problem. Thanks.
typedef typename parent::iterator iterator;
Very well done sir. That was what it was looking for. Thanks a lot.