Question
Compile a class template called MyArray which contains two data members: one called size of type int, and one pointer called myArrayPtr of type parameter
Compile a class template called MyArray which contains two data members: one called size of type int, and one pointer called myArrayPtr of type parameter T. Your class should
(a) Include a constructor that initializes the data member size, allocates memory space (for the array of size elements) to be pointed to by myArrayPtr using the new operator
(b) Include a copy constructor that initializes a MyArray object by making a copy of an existing MyArray object.
(c) Include a destructor that releases the memory allocated by new in the constructor.
(d) Provide a set function to set the ith element of the array and a get function to return the ith element of the array.
(e) Provide a toString member function which returns the string representation of a MyArray object, i.e., return the values of all the elements in the array as a comma delmited list.
have a main function to test your class, and the member functions.
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