user466534
user466534

Reputation:

string function

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

bool isOnlyLeftHand(string w) {
    return (w.find_first_not_of("qwertasdfgzxcvb") == string::npos);
}//end isOnlyLeftHand

Upvotes: 2

Views: 153

Answers (4)

Chubsdad
Chubsdad

Reputation: 25537

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

Upvotes: 1

Robb
Robb

Reputation: 2686

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

Upvotes: 1

Aillyn
Aillyn

Reputation: 23813

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.

Upvotes: 2

Markus Winand
Markus Winand

Reputation: 8746

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

Upvotes: 8

Related Questions