Assignment 1 - Flexible Resizable Array Create a class that implements a safe resizable array, which can contain data of any single type. It should be easy and convenient to use. + Use templates so that the data stored in the arrays can be of any type. + Provide a "default" (no parameter) constructor that sets the array to some reasonable default initial size. + Provide another constructor with one int parameter that allows the programmer to specify the original size. so these would all be possible declarations: { Array A; Array B, C; Array D(100); + Provide a destructor that ensures all heap memory is released when an Array object is destroyed. + Provide set and get methods that allow the programmer to put data into and take data from an Array object, e.g. cout << B.get(3) is like cout << B[3] D.set(i, x*y) is like D[i] = x*y + Make sure your set and get methods check that the index used (3 and i in the above examples) are properly in range. + Provide a change_size(int newsize) method that changes the size of the array, preserving as much of the original data as possible, and carefully recycling any heap memory that is no longer needed. + Make your set method automatically use the change_size method if ever the index used is too big. + Provide a get_size() method that returns the current size of the array. + Provide a set_default method that makes the Array object remember a special default value. Whenever the get method is used with an index that is out of bounds, it should return the default value (if one has been set) instead of reporting an error. + Test it. Here is a dull example { Array Xvals(10); Array Yvals; cout << "size is " << Xvals.get_size() << "\n"; for (int i = 0; i < 30; i += 1) { int x = i*3+1; double y = sin(pi/x); Xvals.set(i, x); Yvals.set(i, y); } cout << "size is " << Xvals.get_size() << "\n"; for (int i = 0; i <= Xvals.get_size(); i += 1) cout << i << ": x = " << Xvals.get(i) << ", sin(pi/x) = " << Yvals.get(i) << "\n"; } It should produce output a lot like this (not necessarily identical) size is 10 size is 30 0: x = 1, sin(pi/x) = 1.22461e-16 1: x = 4, sin(pi/x) = 0.707107 2: x = 7, sin(pi/x) = 0.433884 3: x = 10, sin(pi/x) = 0.309017 4: x = 13, sin(pi/x) = 0.239316 5: x = 16, sin(pi/x) = 0.19509 6: x = 19, sin(pi/x) = 0.164595 7: x = 22, sin(pi/x) = 0.142315 8: x = 25, sin(pi/x) = 0.125333 9: x = 28, sin(pi/x) = 0.111964 10: x = 31, sin(pi/x) = 0.101168 11: x = 34, sin(pi/x) = 0.0922684 12: x = 37, sin(pi/x) = 0.0848059 13: x = 40, sin(pi/x) = 0.0784591 14: x = 43, sin(pi/x) = 0.0729953 15: x = 46, sin(pi/x) = 0.0682424 16: x = 49, sin(pi/x) = 0.0640702 17: x = 52, sin(pi/x) = 0.0603785 18: x = 55, sin(pi/x) = 0.0570888 19: x = 58, sin(pi/x) = 0.0541389 20: x = 61, sin(pi/x) = 0.0514788 21: x = 64, sin(pi/x) = 0.0490677 22: x = 67, sin(pi/x) = 0.0468723 23: x = 70, sin(pi/x) = 0.0448648 24: x = 73, sin(pi/x) = 0.0430222 25: x = 76, sin(pi/x) = 0.041325 26: x = 79, sin(pi/x) = 0.0397565 27: x = 82, sin(pi/x) = 0.0383027 28: x = 85, sin(pi/x) = 0.0369515 29: x = 88, sin(pi/x) = 0.0356923 Error - index out of bounds.