It's for an assignment. The purpose is to create a class that acts a new integer-type of thing. So, our objects should theoretically be able to hold an number of "any" size.
It stores the number as an array of digits (which I chose to use chars for... might be easier to make it an integer array, but it I still need to figure out the c-string constructor at least).
Oh, yeah. I need to give temp some space, shouldn't I?
I think I had something like this at some point, but couldn't get it to work either:
1 2 3 4 5
|
char * temp;
tempDigits = 2;
temp = new char[tempDigits];
temp[0] = '0';
temp[1] = '\0';
|
I have another function I wrote that's an operator overload of the extraction operator (operator<<) that's supposed to allow me to print my arrays. It just doesn't print anything for the ones that don't seem to be working. But it works fine for some.
I tried to run a debugger in Visual Studio but couldn't figure out the actual values that were being put into the arrays for the objects that won't print right, so I'm not sure where the problem is exactly. I've been assuming it's a problem with the assignment of values into the array during the objects' construction.