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
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;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
