I want to make a class that lets you use an int differently. I already have a string class, so I know operators can be overloaded, but I don't know if thats what I need.
Would have the same function asCode:ooint x = 500; x[3] = 1; if (x == 501) cout << x << endl << endl;
or using x%10, etc. to get the digit.Code:int x = 500; char y[5]; itoa(x,y,10); y[3] = 1; x = atoi(y); if (x == 501) cout << x << endl << endl;
The question is, how can I get it to read something in [] as though it was calling a function? I don't want it to directly change the digit, I want to use itoa, change it, then atoi. But I don't know how to let me use x[3] that way.
All I need to know is how to get it to take that as an int called Index in the class.
Thanks!