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

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