Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

5 of 5 View Policies Answered: 1 week ago

Answered: 1 week ago