Skip to content

Commit

Permalink
Update 200.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavpatilX authored Jun 22, 2024
1 parent 4c53964 commit 2cea2af
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions 200.cpp
Original file line number Diff line number Diff line change
@@ -1,61 +1 @@
#include<iostream>
using namespace std;

class ArrayX
{
public:
int * Arr;
int iSize;

ArrayX(int i)
{
cout<<"Allocating the memory for resources...."<<"\n";
iSize = i;
Arr = new int(iSize); // Arr = (int *)malloc(iSize * sizeof(int));
}

~ArrayX()
{
cout<<"Deallocating the memory of resources...."<<"\n";
delete []Arr;
}


void Accept()
{
cout<<"Enter the elements of array : "<<"\n";

for(int iCnt = 0;iCnt < iSize;iCnt++)
{
cin>>Arr[iCnt];
}
}

void Display()
{
cout<<"Elements of array are : "<<"\n";

for(int iCnt = 0;iCnt < iSize;iCnt++)
{
cout<<Arr[iCnt]<<"\t";
}
cout<<"\n";
}
};

int main()
{
int iLength = 0;

cout<<"enter the size of array : "<<"\n";
cin>>iLength;

ArrayX * obj = new ArrayX(iLength); //Dynamic

obj->Accept();
obj->Display();

delete obj;

return 0;
}

0 comments on commit 2cea2af

Please sign in to comment.