Explore BrainMass
Share

List in C++

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Please include the code.

Implement, according to the instructions in parts (a) and (b), the fnction count(), which takes item as argument and returns the number of times item occurs in a list.

template <typename T> -------please see attachment for this portion
int count (const list<T>& aList, constT& item);

a) implement the function by scanning the list and maintaining a count of the number of occurrences of item
b) Implement the function by making repeated calls to seqSearch() until the return iterator is aList.end().

(I have added the code for seqSearch() )

© BrainMass Inc. brainmass.com March 21, 2019, 4:23 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/list-c-183683

Attachments

Solution Summary

It creates the codes to implement the function by scanning the list and maintaining a count of the number of occurrences of item.

$2.19