It's time to convert your listTypeclass into a template class so that you can have lists of ints, floats, strings, or any custom class objects that you could ever imagine. I have attached the solution...


It's time to convert your listTypeclass into a template class so that you can have lists of ints, floats, strings, or any custom class objects that you could ever imagine.


I have attached the solution to Program 4 that you can use to get started, as well as a test program (listTest.cpp) that you can use to test your new "listType.h" file.


For this submission you will only submit the "listType.h" file that contains the template class header and function implementations combined into the single file.




#include #include #include "listType.h" using namespace std; int main() { listType firstList; listType secondList; firstList.add(3); firstList.add(10); secondList.add(3); secondList.add(4); secondList.add(10); if (firstList.isEqual(secondList)) cout < "they="" are="" the="" same!"="">< endl;="" else="" cout="">< "the="" lists="" are="" different"="">< endl;="" cout="">< "the="" contents="" of="" the="" first="" list="" are:="" ";="" firstlist.print();="" cout="">< "the="" contents="" of="" the="" second="" list="" are:="" ";="" secondlist.print();="" cout="">< "assigned="" the="" second="" list="" to="" the="" first="" list."="">< endl;="" firstlist="secondList;" if="" (firstlist.isequal(secondlist))="" cout="">< "they="" are="" the="" same!"="">< endl;="" else="" cout="">< "the="" lists="" are="" different"="">< endl;="" cout="">< "the="" contents="" of="" the="" first="" list="" are:="" ";="" firstlist.print();="" cout="">< "the="" contents="" of="" the="" second="" list="" are:="" ";="" secondlist.print();="" cout="">< "added="" 12="" and="" removed="" 3="" from="" the="" second="" list."="">< endl;="" secondlist.add(12);="" secondlist.remove(3);="" if="" (firstlist.isequal(secondlist))="" cout="">< "they="" are="" the="" same!"="">< endl;="" else="" cout="">< "the="" lists="" are="" different"="">< endl;="" cout="">< "the="" contents="" of="" the="" first="" list="" are:="" ";="" firstlist.print();="" cout="">< "the="" contents="" of="" the="" second="" list="" are:="" ";="" secondlist.print();="" cout="">< "added="" 4="" to="" the="" first="" list."="">< endl;="" firstlist.add(4);="" cout="">< "the="" size="" of="" the="" first="" list="" is:="" "="">< firstlist.size()="">< endl;="" cout="">< "cleared="" out="" the="" second="" list."="">< endl;="" secondlist.clear();="" cout="">< "the="" size="" of="" the="" second="" list="" is:="" "="">< secondlist.size()="">< endl;="" cout="">< "the="" contents="" of="" the="" first="" list="" are:="" ";="" firstlist.print();="" cout="">< "the="" position="" of="" 10="" in="" the="" first="" list="" is:="" "="">< firstlist.search(10)="">< endl;="" cout="">< "the="" element="" at="" position="" 0="" of="" the="" first="" list="" is:="" "="">< firstlist.getelementatposition(0)="">< endl;="" cout="">< "i="" am="" printing="" out="" the="" contents="" of="" the="" first="" list="" from="" a="" 'for="" loop':="" "="">< endl;="" for="" (int="" i="0;">< firstlist.getelementatposition(i)="">< '="" ';="" cout="">< endl;="" cout="">< "the="" current="" max="" size="" is="" :="" "="">< firstlist.maxsize()="">< endl;="" for="" (int="" i="0;"><10000; i++)="" {="" firstlist.add(i);="" }="" cout="">< "the="" current="" max="" size="" is="" :="" "="">< firstlist.maxsize()="">< endl;=""> wordList; wordList.add("I"); wordList.add("have"); wordList.add("a"); wordList.add("cat."); wordList.print(); return 0; }
Apr 18, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here