当我尝试在**行中调用该函数时 通过此功能:
template<class T,int SIZE>
T const& Array<T,SIZE>::const_iterator::operator*() const {
return this->Array<T,SIZE>::iterator::operator*();
}
它给我以下错误:
error: 'Array<int, 3>::iterator' is not a base of 'const Array<int, 3>::const_iterator'
谁能解释为什么?
template <class T, int SIZE>
class Array {
T data[SIZE];
public:
explicit Array();
Array(const Array& a); //copy constructor
~Array(); //destructor
class iterator {
Array<T,SIZE>* array;
int index;
public:
iterator(Array<T,SIZE>* array,int index);
T& operator*() const; //**
};
class const_iterator {
const Array<T,SIZE>* array;
int index;
public:
T const& operator*() const;
};
}