I have the following method:
void* vpArr_t::operator[](int i) const
{
if (!isEmpty() && i >= 0 && i < nOfItems)
{
list<void*>::iterator it;
int idx;
for(it = array.begin(), idx = 0; idx < i; ++it, ++idx); // go to the i'th element
return *it;
}
else
{
return NULL;
}
}
Where:
array
is a list type.
I'm getting a red underline (compilation error) in the following line:
for(it = array.begin(), idx = 0; idx < i; ++it, ++idx);
at:
it = array.begin()
it says that I'm tring to set a list<void*>::const_iterator
into a list<void*>::iterator
type.
But I noticed that there's a iterator
overloading for the begin()
method. how to solve this error? I'm using Visual C++ 2012.