How can I overload the [ ] operator in c++. I basically want to access the index of One-D array and return it. I tried doing this but it doesn't seem to produce the desired result.
Square Square::operator [](const Square& temp)
{
Square obj; //creates a Square class object.
for(int i=0;i<dimension;i++)
{
*obj.board = temp.board[i];
}
return obj;
}