Question
C++ Programming: data structures This one will be based on an array, but will provide more features than a plain old array. You will implement
C++ Programming: data structures
This one will be based on an array, but will provide more features than a plain old array. You will implement the following as part of your class, which we will call 'FancyList':
* a private pointer to an array of integers called 'arrayPtr'
* a private int called size, and an accessor and mutator for size -- size will start at 0 and increase every time a new item is added
* a private int called maxSize that will be used to initialize your array. maxSize will default to 10
* a constructor and overloaded constructor. the overloaded version supplies a new value for maxSize to choose how big the array should be
* a public method addItem that uses the current size to figure out where to put the new item in the array pointed to by 'arrayPtr' (our list). If the size == maxSize, then maxSize will be increased by double, and the array will be copied to a larger array and the old array will be deleted, and the new array will be pointed to by arrayPtr
* overloaded operators: >>, == (insertion and equality). The == operator will return true if all items are the same and in the same order. The >> operator will be used to display the contents of the list.
* a destructor that will delete the arrayPtr to avoid memory leaks
* a public method that will return the array as a std::vector
* instead of hard coding an array of integers, use templates to allow other types
* implement the addition + operator so two lists can be merged into one larger list
In your application file, make sure to create an instance of FancyList with the default and then the overloaded constructor. Demonstrate all methods in use.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started