more operator overloading

BKurosawa's Avatar, Join Date: Jul 2007
Newbie Member
I get this error with this code:

error C2662: 'IntArray::translateIndexToZeroBased' : cannot convert 'this' pointer from 'const IntArray' to 'IntArray &'

Code:
int& IntArray::operator [](int index)
{
	static int sink;
	int zerobasedindex = translateIndexToZeroBased(index);
	if(zerobasedindex < 0 || zerobasedindex >= theSize)
	{
		cout<< "Problem with index (less than 0)" << endl;
		return sink;
	}

	return parray[zerobasedindex];
}

const int& IntArray::operator [](int index) const
{
	static int sink;
	int zerobasedindex = translateIndexToZeroBased(index);
	if(zerobasedindex < 0 || zerobasedindex >= theSize)
	{
		cout<< "Problem with index (l)" << endl;
		return sink;
	}
	return parray[zerobasedindex];
}
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Can you share the function declaration and function definition of translateIndexToZeroBased