2

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

4 Answers 4

8

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

Sign up to request clarification or add additional context in comments.

5 Comments

except that 'b' is keyed in with the right index finger if you are not already down with several mugs!
@chubsdad I always use the left index finger to type 'b'
@Aillyn: library.thinkquest.org/18709/data/keys.html. Not sure if we have a standard for this too :)
@chubs: me too. I'm left handed. And I'm not drunk.
my initial research says that this is also an 'implementation defined' behavior. And I am not drunk too at least for now!.
2

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.

Comments

1

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.