Write a generic countmatches function that takes two


Question: Write a generic countMatches function that takes two parameters. The first parameter is an array of int. The second parameter is a function object that returns a Boolean.

a. The method countMatches returns the number of array items for which the function object returns true. Implement countMatches.

b. Test countMat ches by writing a function object EqualsZero that overloads operator ( ) to accept one parameter and returns true if the parameter is zero. Use an EqualsZero function object to test countMatches.

c. Rewrite countMatches (and ~quals~ero) by using templates.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write a generic countmatches function that takes two
Reference No:- TGS02475094

Now Priced at $15 (50% Discount)

Recommended (92%)

Rated (4.4/5)