Question: Please use C++ for this problem. Please refer to the samples as how the output show look. Implement a class named MyInteger that stores an

Please use C++ for this problem. Please refer to the samples as how the output show look.

Implement a class named MyInteger that stores an integer and has functions to get and set the integer value. Then, overload the [] operator so that the index returns the digit in position i, where i = 0 is the least-significant digit. If no such digit exists then -1 should be returned. For example, if x is of type MyInteger and is set to 418, then x[0] should return 8, x[1] should return 1, x[2] should return 4, and x[3] should return -1. Assume your program is being run on a 32-bit computer, where the largest value that can be stored in a 2 byte int is 32,767. Test your class by prompting the user to enter an integer, then use the overloaded subscript operator to print the digit in all 5 positions.

Sample 1 : Enteranintegervalueforx:32767 x[0]=7 x[1]=6 x[2]=7 x[3]=2 x[4]=3

Sample 2 : Enteranintegervalueforx:1 x[0]=1 x[1]=-1 x[2]=-1 x[3]=-1 x[4]=-1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!