Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please program in c++, and also make it easy to read. 1.1 Class Requirements You will be writing code for a Ct+ class that acts
please program in c++, and also make it easy to read.
1.1 Class Requirements You will be writing code for a Ct+ class that acts as a more advanced array The class must have the following two private member variables: A. A pointer to an integer (that will be used to point to a dynamically allocated integer array) A variable that holds the size of the dynamically allocated integer array B. The class must have the following four public member functions: I A constructor (a member function with the same name as the class) that receives one input parameter: the desired size of the dynamically allocated integer array . The constructor should create a dynamic array of the requested size (using new) and store its pointer in the class's corresponding private member variable (A above) .The constructor must also store the input size in the class's corresponding private member variable (B above) IL A function that writes an integer (input parameter #1) into a given index of the array (input parameter #2) The function must verify that the input index doesn't exceed the size of the array. Return true if a valid index, or false for an invalid index. 111. A function that returns an integer from a given index of the array (input parameter #1) The function must verify that the input index doesn't exceed the size of the array. If the index is invalid, indicate this to the code that calls the function (in a manner of your choosing) IV. A function that searches the array for a given value (input parameter #1) Return the index of the first location of the array that contains the given value, or returna negative number if the value is not found e You can search the array with a simple loop that iterates through each array index and compares cach array value against the input value Hint: See the triangle class in the first few pages of the notes on Classes and Structures for an example of how to write code for a class. Note: You are not required to write a destructor for your class (because I haven't covered this yet), but it would be very simple. A good destructor would delete the dynamically allocated integer array to ensure that no memory is I 1.2 Main Code Requirements Your main code must do the following: .Create (instantiate) a variable of your class type When creating the variable, make sure the input parameter (the size that is given to the constructor) is large enough to handle the following data o .Add the 9 separate digits of your Banner/student ID to the class's array with the help of function II above Receive an input integer from the user Search for the input number in your student ID using function IV above . . If the number is found, overwrite the number with-1 using function II above Display all the numbers in the class's array with the help of function III aboveStep 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