Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Langauge 13. (12 pts) Add a member function found to a given listType class.

ID: 3736526 • Letter: C

Question

C++ Langauge

13. (12 pts) Add a member function found to a given listType class. The function will find out how many copies of ItemType value exist in the dynamic array pointed by the data member ptrItems and return the result. If the value is not in the list at all, the function will return 0. typedef int ItemType // a general list class class listType public: int found (ItemType value) // Pre: self obj and value initialized // Post: return number of times value occurs in the self obj return 0 if value not in the list private: ItemType ptrItems / points to the dynamic array int size; // number of items currently in the array. Items are at position 0 to size-1

Explanation / Answer

int listType::found(ItemType value) {
   int count = 0;
   for(int i = 0; i < size; ++i) {
       if(ptrItems[i] == value) {
           ++count;
       }
   }
   return count;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote