开发者

string function

please can anybody explain me what this function do?i am confused

bool isOnlyLeftHand(str开发者_如何转开发ing w) {
    return (w.find_first_not_of("qwertasdfgzxcvb") == string::npos);
}//end isOnlyLeftHand


Returns true if the string can be entered with the left-hand only (on the keyboard) :)


This looks for characters that are not any of qwertasdfgzxcvb in the string w, and returns true if none are found (note the double negation).

In other words, return true if w can be typed using the left hand side of the keyboard.


It is literally checking for characters within the string that would be typed with the left handed.

The code find_first_not_of will scan the string and find the first position that is not part of the input w


returns true if any character other than those in the quoted string is absent in the input string represented by 'w'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜