Question: See the code below. Write the template based class implementation of function object neq which compares a given data element against a target and returns

See the code below.

Write the template based class implementation of function object neq which compares a given data element against a target and returns true if the two are different. Also write template based function count( ) which determines how many elements in the search range specified by two list iterators do not equal a specified target.

For example, if the input is 1 3 2 4 3 2 4 1 and the target is 2 the output is Found 6 elements....

Hint: Seek inspiration from the STL_intro_handout.

#include

#include

using namespace std;

int main(int argc, char *argv[]) {

list v;

list::iterator iv;

int value, target;

while (cin >> value)

v.push_back(value);

cin.clear();

cout << "Set target ";

cin >> target;

int N = count(v.begin(), v.end(), neq(target));

cout << "Found " << N << " elements not equal to target ";

}

please help, this is all the question thanks

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!