Gudday everyone,
In class we need to recreate part of an STL library (namely the 'set' class) and apply it only for integers. I was trying to define constructors for the iterator and a couple of operators but every instance of 'iterator' throws the error below:
I'm sure it's an elementary mistake, but it's going to be one that I'll never make again.
Thanks for any advice in advance,
Sammich.
In class we need to recreate part of an STL library (namely the 'set' class) and apply it only for integers. I was trying to define constructors for the iterator and a couple of operators but every instance of 'iterator' throws the error below:
Code:
ISO C++ forbids declaration of 'iterator' with no type
Thanks for any advice in advance,
Sammich.
Code:
//IntSet.h
#include <vector>
using std::vector;
class IntSet {
std::vector<int> set;
public:
// constructors
IntSet(void);
IntSet(const IntSet&);
IntSet(vector<int>::const_iterator, vector<int>::const_iterator);
//access methods
int size() const;
void add(int v);
bool remove(int v);
bool contains(int v);
bool empty(void) const;
//begin iterator
typedef vector<int>::iterator iterator;
typedef vector<int>::const_iterator const_iterator;
iterator(void);
iterator(const &iterator);
iterator begin() { return set.begin(); }
const_iterator begin() const { return set.begin(); }
iterator end() { return set.end(); }
const_iterator end() const { return set.end(); }
bool operator==(const &iterator);
bool operator!=(const &iterator);
//end iterator
IntSet operator*();
bool operator!=(IntSet&);
bool operator==(IntSet&);
IntSet operator+(const IntSet&);
IntSet operator*(const IntSet&);
IntSet operator-(const IntSet&);
};