Question: C++ a) Write a recursive function in C++ with the following prototype: int getWholeNumber(string s); The function should recognize a possibly empty sequence of base
C++

a) Write a recursive function in C++ with the following prototype: int getWholeNumber(string s); The function should recognize a possibly empty sequence of base 10 digits and return the corresponding value as a nonnegative integer, or return -1if the string contains any non-digits. For the recursive case, call the function on s.substr(0, s.length-1). In the special case where s is empty string the function should return 0. (This can be your base case.) b) Write a function int getInteger(string s, bool & isValid); that recognizes valid integers. That means a nonempty sequence of digits, possibly preceded by a single minus sign. If the string is not a valid integer, then the function should set isValid to false and return O. If the string is a valid integer then the function will set isValue to true and return the corresponding integer value. Your code should call getWholeNumber from Part a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
