Lab 4 - Challenge Pointer Lab
Objective
Design and implement a program to manipulate a dynamic array using C++ pointers. This project will help you understand the concept of pointers, dynamic memory allocation, and array manipulation in C++.
Requirements
Create a class called
DynamicArray
with the following attributes:array (pointer to int)
size (int)
Add the following methods to the
DynamicArray
class:A constructor to initialize the size attribute and allocate memory for the array.
A destructor to deallocate the memory allocated for the array.
A method called
setArrayElements()
to set the values of the array elements using pointer arithmetic.A method called
resizeArray()
to resize the array to a new size (allocate new memory, copy old data, and deallocate old memory).A method called
display()
to print the array elements using pointer arithmetic.A method called
sum()
to return the sum of the array elements using pointer arithmetic.A method called
getMax()
to return the maximum value in the array using pointer arithmetic.A method called
getMin()
to return the minimum value in the array using pointer arithmetic.
In the
main()
function, create aDynamicArray
object and use the methods to perform various operations like setting array elements, resizing the array, displaying the array elements, finding the sum, maximum, and minimum of the array elements. Demonstrate the use of theDynamicArray
class by simulating dynamic array manipulation.
Deliverable
Upload the following:
Full source code (.cpp files or .txt files)
Screenshot of the Console with the code executing
2024 - Programming 3 / Data Structures - Author: Dr. Kevin Roark