Question: PROJECT: High-precision arithmetic is required in many different fields of study. One area where it is used is public-key cryptography, where information is encoded and
PROJECT:
High-precision arithmetic is required in many different fields of study. One area where it is used is public-key cryptography, where information is encoded and decoded using integers more than 100 digits long. In the interest of being able to handle such long integers as these, this project asks you to implement a class that can read in, store, print, and add very long positive integers. Provide a complete program that includes a VeryLongInt class that contains one data member - a char vector named digits. Why char? Because a char requires less storage space than the standard numeric types - only 8 bits for a char as compared to 32 bits for an int. And saving space can be important for programs that use lots of very long integers.
Your VeryLongInt class should contain:
A 0-parameter constructor that stores a default value of '0' in the vector.
A 1-parameter constructor that stores the passed in string parameter, numStr, in the vector. Store each of numStr's char digits as an element in the digits vector. If any of numStr's char "digits" is not a digit, print an error message and store a default value of '0' in the vector.
An overloaded >> input operator that stores the user-entered value in the vector. Store each char from the user-entered value as an element in the digits vector. If any of the user-entered char "digits" is not a digit, print an error message and store a default value of '0' in the vector.
An overloaded << output operator that prints the contents of the vector.
An overloaded + operator that adds two VeryLongInt objects and returns the sum in the form of a new VeryLongInt object.
At least one appropriate helper member function.
Since this is a non-trivial program (my implementation is four total pages of code including the given driver
file and the extra credit), you are required to break it up into separate files in the standard manner. Use these
files:
veryLongInt.h: for the VeryLongInt class definition
veryLongInt.cpp: for member function definitions and overloaded << and >> friend functions.
veryLongIntDriver.cpp: for driving the VeryLongInt class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
