#include <vector>
#include <iterator>
template <typename T>
class list
{
public:
list() {};
~list() {}
list operator=(T rhs[])
{
vect.insert(vect.being(), rhs, sizeof(rhs)); return *this;
}
void append(T item)
{
vect.push_back(item);
}
void insert(int position, T item)
{
vect.insert(vect.begin() + position, item);
}
int count(T item)
{
int total = 0;
for (iter = vect.begin(); iter != vect.end(); ++iter)
{
if (*iter == vect)
{
total++;
}
}
return total;
}
private:
std::vector<T> vect;
typename std::vector<T>::iterator iter;
};
And GCC is giving me this error:
C:\C++\include/list.hpp:27:4: error: no match for'operator==' in '((list<int>*)this)->list<int>::iter.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<int*, std::vector<int, std::allocator<int> > >() == ((list<int>*)this)->list<int>::vect'
I am not sure (cannot test here).... but is it possible that the problem could be fixed replacing line 35 with
typename std::vector<T> vect;
?
Becouse the problem is surely dependant by "iter = vect.begin();" in line 25...
I have very little experiences with template and iterators, but I noticed that sometimes initializing an iterator with "begin" can be not so immediate...