Hey yall, so I have once again stumbled upon an overloading problem. For this class project, we pretty much have to make a class for a type that handles extra large integers (up to 40 digits). Part of the assignment is overloading the output operator so we could just do "cout<<obj" and that's where I'm having trouble. The array is stored in private as just a pointer to the beginning of the array. The array is size 40 and stores the number itself at the end of the array i.e. {0,0,0,0,0,0......,9,9,9,9} = 9999 etc. I have attached what I have so far, but it just prints out nothing. arrSize is the size of the array, numSize is the size of the number in the array, and ptr is the array itself, also I only want the number itself, not the leading zeros. If anyone has any ideas or tips I would greatly appreciate them.
I tried that condition and it worked better, but now it is only outputting the final digit of the object (if the object is {1234} it prints n1 is 4). numSize is a member of my class but it had to be static and initialized outside of the class itself to be used there. IDK if that caused any problems but I know it may have. I think my a big issue is the arrSize-numSize, but that's the only way i could think of passing over the leading zero's. I know there's probably some fancy function or secret c++ command I don't know about, but that's what i got for now.
numSize is a member of my class but it had to be static and initialized outside of the class itself to be used there.
You're missing the point of my #2. numSize should not be static. Consider that you may have two myIntegers in your program with different number of digits. How are you going to print those? You certainly don't want to modify numSize before printing each one. For example, the following: