I tried to write a class called Mystring which basically does everything std::string class can do. Right now I'm trying to write a MyString::rfind function which will match a short string with the long string(just like the rfind function for string class). However, when I run the code nothing gets printed out in the console. Can anyone spot where the problem is?
//cpp 
size_t MyString::rfind(const MyString& str, size_t pos) const {
    if (str.size() == 0 && pos < s.size()) { return pos; }
    if (str.size() == 0 && pos > (s.size() - 1) ) { return s.size(); }
    size_t a = std::min(pos, (s.size() - 1));
    for (size_t i = a; i >= 0; --i) {
        if (s[a] == str.s[0]) {
            for (size_t b = 1; b < str.size(); ++b) {
                if (s[i + b] != str.s[b]) { break; }
                if (b == (str.size() - 1)) { return i; }
            }
            return -1;
        }
    }
    return -1;
}
//main
int main(){
 
const MyString testMyString = "0123456789";
cout << testMyString.rfind("647")<< endl;
return 0;
}
 
    