Question: A useful member function of the string class is find. The call str . find ( ch ) returns the position of the first occurrence

A useful member function of the string class is find. The call str.find(ch) returns the position of the first occurrence of ch in str, or the "special" value, string::npos if there is no match. We could have implemented the first_space function as return str.find(""). However, that function is not useful if we have alternatives, such as "any vowel".
Implement a function that uses the find member function and finds the first position of any characters from a set in a given string. For example, first_in_set("spring", "aeiou") returns 3 because "i" occurs in the set "aeiou" and the preceding characters do not.
If there is no match, then return -1.
Use multiple return statements. As soon as you have computed the answer, return it.

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!