Dynamic Array Class
Explore how to implement a dynamic array class in C++ that merges two sorted arrays into a third sorted array. Understand class functions like create, sort, merge, and display, and learn to manage dynamic memory using pointers to handle arrays of varying sizes.
We'll cover the following...
We'll cover the following...
Problem
Merging of arrays involves two steps; sorting the arrays that are to be merged, and adding the sorted elements of both the arrays to a new array in sorted order. Write a program that merges two arrays into a third array.
Sample run
Here’s what you should see when you run the program.
Enter elements for first array:
Enter the element no. 1 67
Enter the element no. 2 12
Enter the element no. 3 -4
Enter the element no. 4 43
Enter the element no. 5 2
Enter elements for second array:
Enter the element no. 1 8
Enter the element no. 2 10
Enter the element no. 3 -2
Enter ...