Create a class of function objects called StartsWith that satisfies the following specification: when initialized with character c, an object of this class behaves as a unary predicate that determines if its string argument starts with c. For example, StartsWith(’a’) is a function object that can be used as a unary predicate to determine if a string starts with an a. So, StartsWith(’a’)("alice") would return true but StartsWith(’a’)("bob") would return false. The function objects should return false when called on an empty string. Test your function objects by using one of them together with the STL algorithm count_if to count the number of strings that start with some letter in some vector of strings. So basically, I want a class that returns true or false based on if the name that is typed starts with the charac
This is in c++.
Create a class of function objects called
StartsWith
that satisfies the following specification: when initialized with character c, an object of this class behaves as a unary predicate that determines if its string argument starts with c. For example,
StartsWith(’a’)
is a function object that can be used as a unary predicate to determine if a string starts with an a. So,
StartsWith(’a’)("alice")
would return true but
StartsWith(’a’)("bob")
would return false. The function objects should return false when called on an empty string. Test your function objects by using one of them together with the STL
So basically, I want a class that returns true or false based on if the name that is typed starts with the character that I put down.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images