Dynamic Array and Linked List
- h: declare a class VectorADT to manage a dynamic array of doubles
- cpp: implement VectorADT’s member and non-member functions as declared in VectorADT.h
- h: declare a class ListADT to manage a linked list of integers
- cpp: implement ListADT’s member and non-member functions as declared in ListADT.h
- cpp: test the above member and non-member functions.
- The interface of VectorADT is required to include the following functions:
- a default constructor to initialize the data members as follows: 0–>size, 10->capacity, and allocating a space of 10 doubles to array (of course). Don’t forget to initialize each element on array to 0.00.the “big-3”: destructor, copy constructor and overloaded assignment operatorvoid push_back(intval ); This member function inserts the value ‘val’ to the end of the dynamic arrayvoid resize(intnewSize); This member function Resizes the container so that it contains newSize elements. If newSize is smaller than the current container size, the content is reduced to its first newSize elements. You don’t have to reduce the capacity in this case. If newSize is greater than the current container size, the content is expanded by inserting at the end as many elements as needed to reach a size of newSize. You are required to initialize all the new elements to 0.00. If newSize is also greater than the current container capacity, make sure you increase the capacity to 2*newSize, i.e., double the value of newSize. For example, if the current value of capacity is 100 and newSize is 150, your program is going to reallocate memory to increase the capacity of array to 300.
- voidpop_back(); This member function deletes the last number from the array, i.e., it decreases the size of the container by 1.
- Overload the operator[ ] as a read-only member function to return the i-th element in array. Assume v1 is a VectorADT object, this operator allows one to retrieve the i-th element on array if i is valid using the statement v1[ i ];.
- Overload the addition operator (operator+) as a member function to add two VectorADT objects, say v1 and v2 if they are of the same size. This member function is not allowed to change either of its two operands. It returns a VectorADT object corresponding to the sum of v1 and v2. With this operator, one can add v1 and v2 as follows: v3 = v1+v2;
- Overload the put operator (i.e., operator<<) as a friend function to print out all the elements stored in a VectorADT object. For example, assume the VectorADT object v1 contains the following numbers 1.10, 21.12, -0.81. One can write cout<
VectorADT.cppThis program file implements the above list of functions declared in VectorADT.h