Some additional information: getIndex function (using linear search): 1) Accepts a value of type T as a parameter. 2) Iterate through the array checking if the value is in the array. If it is return...


NEED HELP WITH THIS C++ QUESTION


Some additional information:<br>getIndex function (using linear search):<br>1) Accepts a value of type T as a parameter.<br>2) Iterate through the array checking if the value is in the array.<br>If it is return the index.<br>If it is not, return -1.<br>Example<br>Given 5 10 15 20 25 30 and value 15, return the index 2.<br>erase function:<br>1) Accepts an index as a parameter.<br>2) Use a loop to shift all elements from the index to the end of the<br>array to the left by 1.<br>3) Decrement size by 1.<br>Example<br>Given 5 10 15 20 25 30 and index 3 we would shift 25 and 30 to the left<br>thereby overwriting the number 20 resulting in the array 5 10 15 25 30.<br>

Extracted text: Some additional information: getIndex function (using linear search): 1) Accepts a value of type T as a parameter. 2) Iterate through the array checking if the value is in the array. If it is return the index. If it is not, return -1. Example Given 5 10 15 20 25 30 and value 15, return the index 2. erase function: 1) Accepts an index as a parameter. 2) Use a loop to shift all elements from the index to the end of the array to the left by 1. 3) Decrement size by 1. Example Given 5 10 15 20 25 30 and index 3 we would shift 25 and 30 to the left thereby overwriting the number 20 resulting in the array 5 10 15 25 30.
Implementation<br>Implement a class SomeObj:<br>1) data member:<br>a) id<br>an integer named<br>2) constructors:<br>a) default<br>b) single parameter constructor to set the value of id<br>3) functions:<br>a) getId<br>return the value of id<br>a) output<br>output the value of id to console<br>Implement a Template Class MyArray (modify/augment example 12.6):<br>1) data members:<br>a) data<br>dynamic array of type T<br>b) capacity<br>c) size<br>capacity of the dynamic array<br>number of elements in the array<br>2) constructors:<br>- create an empty array of capacity 10<br>- create an array of a specified capacity<br>a) default<br>b) single parameter<br>3) functions:<br>a) getSize<br>b) getCapacity<br>return the size<br>return the capacity<br>b) grow<br>private grow function (capacity*2) +1<br>given a value, return its index or -1 if not found<br>c) getIndex<br>use a linear or binary search<br>d) push_back<br>append element to the end of the array<br>- remove the element at the specified index<br>- overloaded [] operator (regular and const versions)<br>e) erase<br>f) []<br>4) the big three<br>A Non-Member Print function:<br>1) Prints the contents of a template MyArray object given via as a parameter.<br>Main:<br>1) Instantiate a template MyArray object of SomeObj pointers.<br>2) Instantiate 10 SomeObj objects and append them to the MyArray object.<br>3) Print the SomeObj contents of the MyArray object.<br>

Extracted text: Implementation Implement a class SomeObj: 1) data member: a) id an integer named 2) constructors: a) default b) single parameter constructor to set the value of id 3) functions: a) getId return the value of id a) output output the value of id to console Implement a Template Class MyArray (modify/augment example 12.6): 1) data members: a) data dynamic array of type T b) capacity c) size capacity of the dynamic array number of elements in the array 2) constructors: - create an empty array of capacity 10 - create an array of a specified capacity a) default b) single parameter 3) functions: a) getSize b) getCapacity return the size return the capacity b) grow private grow function (capacity*2) +1 given a value, return its index or -1 if not found c) getIndex use a linear or binary search d) push_back append element to the end of the array - remove the element at the specified index - overloaded [] operator (regular and const versions) e) erase f) [] 4) the big three A Non-Member Print function: 1) Prints the contents of a template MyArray object given via as a parameter. Main: 1) Instantiate a template MyArray object of SomeObj pointers. 2) Instantiate 10 SomeObj objects and append them to the MyArray object. 3) Print the SomeObj contents of the MyArray object.
Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here