Question: C++ Question Why this throws an error? // cpp size_t MyString::rfind(char c, size_t pos) const { while (pos != -1) { if (s.at(pos) == c)
C++ Question
Why this throws an error?
// cpp
size_t MyString::rfind(char c, size_t pos) const { while (pos != -1) { if (s.at(pos) == c) { return pos; } else { return pos--; } }
return -1; }
// main
int main() {
const MyString testMyString = "0123456789";
cout << testMystring.rfind("648") << endl;
cout << testMystring.rfind("648", 20) << endl;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
