#include #include using namespace std; //…

Question Answered step-by-step #include #include using namespace std; //… #include #include using namespace std;// ————– Design Merge class here —————// ———————————————————–// Use template class for Merge class ,i.e., Merge objectNName;// No private/public variable or data member//  No need for constructor// Write the following functions:// – merge function that take vector of vector//   – write code that solve the problem of merging intervals that overlap//   – implement exception handling for given (vector of vector) that have less than two intervals, e.g., [(1,2)] this is not accepted as input. because it has only one interval//   – use error handling: try, throw, and catch// – print function that print out intervals// example of merging the following intervals: [(2,5),(1,4),(3,9),(20, 29),(7,16), (15, 27)];//1   2   3   4   5   6   7   8   9   10  …  15  16  17  18 … 20 … 27   28  29//    *———–*//*———–*//        *———————–*//                                                                 *—————-*//                         *————————-*//                                               *————————*// The merge result wil be interval from 1 to 29//*———————————————————————————* int main() {   vector> array1, array2, array3, array4;   vector> ans;   //Make object of Class Merge with template T used as int   Merge s;   array1 = {{2,5},{1,4},{3,9},{20, 29},{7,16}, {15, 27}};   array2 = {{1,3},{2,6},{8,10},{15,18}};   array3 = {{2,5},{6,10},{15,20},{30,31}};   array4 = {{1,4}};   // Merge first array and print   cout << "array 1 after merge: n";   ans = s.merge(array1);   s.print(ans);   // Merge second array and print   cout << "narray 2 after merge: n";   ans = s.merge(array2);   s.print(ans);   // Merge third array and print   cout << "narray 3 after merge: n";   ans = s.merge(array3);   s.print(ans);   // Merge forth array and print   cout << "narray 4 after merge: n";   ans = s.merge(array4);   s.print(ans);   return 0;} Computer Science Engineering & Technology C++ Programming HLI 553A Share QuestionEmailCopy link Comments (0)