In a previous lab you created a function called isNaN that would check to see if a
Fantastic news! We've Found the answer you've been seeking!
Question:
In a previous lab you created a function called isNaN that would check to see if a string contains a valid number. For this assignment create a function called recursiveNaN that uses recursion to check to see if the string contains a valid number. This function should be in the private section of the class.
So to not break the interface call recursiveNaN from the isNaN function.
I have two instances of isNan:
//double.cpp
void Double::isNan(string s) { int pos; this->nan = false; pos = s.find(\".\", 0); if (pos != string::npos) { pos = s.find(\".\", pos + 1); if (pos != string::npos) { this->nan = true; return; } } string::iterator p; for (p = s.begin(); p { if (!isdigit(*p) && *p != '.') { this->nan = true; return; } } return; }
//integer.cpp
void Integer::isNaN(string s) { this->nan = false; string::iterator p; for (p = s.begin(); p { if (!isdigit(*p) && *p != '.') { this->nan = true; return;
Related Book For
Intermediate Accounting
ISBN: 978-0324300987
10th Edition
Authors: Loren A Nikolai, D. Bazley and Jefferson P. Jones
Posted Date: