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

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;

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 Programming Questions!