Below is a class called pointerDataClass that store data in a one-dimensional array using pointer. #include<iostream> using namespace...

80.2K

Verified Solution

Question

Programming

Below is a class called pointerDataClass that store data in aone-dimensional array using pointer.

#include

using namespace std;

class pointerDataClass

{ int maxSize;//variable to store the maximum size of p

int length;//variable to store the number of elements in p

int *p;// pointer to an int array

public:
//Constructor to create an array of the size specified by theparameter size.

pointerDataClass(int size);

//Destructor to deallocate the memory space occupied by thearray p

~pointerDataClass();

//the function insertAt inserts num into array p at the positionspecified by  
//index

void insertAt(int index, int num);

//The function displayData displays all the array elements inp

void displayData();

   };

  1. Implement (write code) all constructors, functions, and thedestructor ~pointerDataClass.   
  2. Write a main function to perform the following:
    • Create a pointerDataClass object called list11 with a size of10 elements
    • Insert the following numbers into the array p of the objectlist11:
      0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
    • Display the array p of the object list11

PLEASE DO THIS WITH C++

Also, using declaration of array and using [] notationfor accessing element of array

Answer & Explanation Solved by verified expert
4.1 Ratings (693 Votes)
CPP codeincludeusing namespace stdclass pointerDataClass int maxSizevariable to store the maximum size ofp int lengthvariable to store the number of elementsin p int p pointer to an int array public Constructor to create an array of the size specifiedby the parameter size pointerDataClassint size    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students