Thank you though.
Originally posted by elad
//crude prefix increment operator for an ooint class
ooint operator++ ()
{
++myInt;
return *this;
}
It's stored as a string, so I'd have to use itoa(++converttoint(),CString,10);
[EDIT]
Fixed that, ++ now works:
Code:
const ooint & ooint::operator++ ()
{
int myInt = converttoint();
++myInt;
char *s = itoa(myInt,CString,10);
int len = 0; // length of newly constructed string
assert(s != 0); // make sure s non-NULL
len = strlen(s); // # of characters in string
// free old string if necessary
if (Capacity < len + 1)
{
delete[] CString; // delete old string
Capacity = len + 1; // add 1 for '\0'
CString = new char[Capacity];
}
strcpy(CString,s);
return *this;
}
Thanks so much Elad!