In an old C++ book I have, the following example is given for overloading the  operator:
int &IntArray::operator (int index)
static int dummy=0;
if((index=0) && (index < length))
cout << "Error: index out of range.\n";
where length and array are member variables of the class IntArray.
My question is as follows. Suppose you have this code:
Since somearray returns a reference to data in somearray and somearray goes out of scope before x does, wont bad things happen when Dosomethingwith() tries to use x?