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

  1. Create a class called DynamicArray with the following attributes:

    • array (pointer to int)

    • size (int)

  2. 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.

  3. In the main() function, create a DynamicArray 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 the DynamicArray class by simulating dynamic array manipulation.

Deliverable

Upload the following:

  1. Full source code (.cpp files or .txt files)

  2. Screenshot of the Console with the code executing

2024 - Programming 3 / Data Structures - Author: Dr. Kevin Roark