How can I get around this without using static?
In other words, this works fine if the value entered is an int or float.
If it is a character array (the isint and isdouble functions both returned false), then it assigns the pointer and works correctly inside the overload.
When the overload ends, the pointer goes out of scope.
If I use static, it works, but then if you use it again with a different any, it changes BOTH values, which is BAD!
istream& operator >>(istream & is, any & operand)
//precondition: input stream is open for reading
//postcondition: the next string from input stream is has been read
// and stored in operand
static char temp; // not longer than screen length
int i = 0;
while (i <= 80 && is.get(ch) && ch != '\n')
temp[i++] = ch;
temp[i] = '\0';
//cout << any_cast<char*>(operand) << endl;
if (isint(temp)) // if it is an integer, convert it to one
operand = atoi(temp);
else if (isfloat(temp)) // if it is a float or double, convert it to one
operand = atof(temp);
else // otherwise, just store a string
operand = temp;