Question: Based on BubbleSortT function above: a. Modify the BubbleSortT function to take as parameter a new templated class called MyList, instead of a vector.

Based on BubbleSortT function above: a. Modify the BubbleSortT function to take


as parameter a new templated class called MyList, instead of a vector.

Based on BubbleSortT function above: a. Modify the BubbleSortT function to take as parameter a new templated class called MyList, instead of a vector. b. Define MyList so that it can be initialized with an array. c. Define an overloaded operator < < that takes MyList and outputs its contents to the std:ostream. d. Use the above in the following Test () function: void Test () { const std:size_t arraySize = 10; short shortArr [ arraySize ] = { 2, 6, 4, 8, 10, 12, 89, 65, 44, 37 }; double doubleArr [ arraySize ] = { 2.0, 6.0, 4.0, 8.0, 10.0, 12.25, 89.99, 65.0, 45.0, 37.0 }; std:string strArr [ arraySize ] = { "two", "six", "four", "eight", "ten", "twelve", "eighty nine", "sixty five", "forty four", "thirty seven" }; MyList shortList ( shortArr, arraySize ); MyList doubleList ( doubleArr arraySize ); MyList strlist ( strArr, arraySize ); std:cout < < shortList < < std:endl; BubbleSortT ( shortList ); std:cout < < shortList < < std:endl; std:cout < < doubleList < < std::endl; BubbleSortT ( doubleList ); std::cout < < doubleList main.cpp //Assignment 5.cpp by Tyler Hayes #include "BubbleSortT.h" int main() Test (): return 0: BubblesortT.cpp //BubbleTemplate.cpp by Tyler Hayes #include "BubblesortT.h" void Test (0 std::vector shortArr; shortArr.push_back (2); shortArr.push_back (6) ; shortArr.push_back (4); shortArr.push_back (8); shortArr.push_back (10); shortArr.push_back (12) ; shortArr.push_back (87) ; shortArr.push back (68) ; shortArr.push back (45) ; shortArr.push back (38) ; BubblesortT( shortArr ); std::vector doubleArr; doubleArr.push_back (2.0): doubleArr.push_back (6.0); doubleArr.push_back (4.0): doubleArr.push_back (8.0); doubleArr.push_back (10.0); doubleArr.push_back (12.0); doubleArr.push back (87.0): doubleArr.push back (68.0); doubleArr.push back (45.0); doubleArr.push_back (38.0); BubblesortT( doubleArr ); std::vector stringArr; stringArr.push_back ("two"): stringArr.push_back ("six"); stringArr.push_back ("four"); stringArr.push back ("eight") : stringArr.push back ("ten"); stringArr.push back ("twelve"); stringArr.push_back ("eighty seven"): stringArr.push back ("sixty eight"): stringArr.push_back ("forty five"); stringArr.push_back ("thirty eight"); BubblesortT( stringArr ): BubblesortT.h //BubbleTemplate.h by Tyler Hayes #ifndef BUBBLESORTT_H #define BUBBLESORTT_H #include tinclude #include tinclude using std: :setw; using std::cout; using std: :endl; using std: :size_t; template void BubblesortT (std::vector 6 List) T hold; bool swapMade; cout < < "Data items in original order:" < < endl; for ( size_t i - 0; i < List.size (); ++i ) cout < setw (16) < < List [ i ]; } // for i SwapMade - true; for ( size t pass - 0; pass < List.size () && swapMade; ++pass) cout < < " ---New Pass--- swapMade - false; for ( size_tj - 0; j < List.size() - 1; ++j ) if ( List [ il > List [j +11) hold - List [ ); List [j] - List [j + 1 ]; List [j + 11 - hold; cout < < " Swap made:" < < endl; for ( size_t i - 0; i < List.size (); ++i ) cout < < setw (16) < < List [ i ]; swapMade - true; }// if else swapMade - false; //cout < < " (No swap) " < < endl;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer File Name MyListh ifndef MYLISTH define MYLISTH include using namespac... View full answer

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 Programming Questions!