-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c53964
commit 2cea2af
Showing
1 changed file
with
0 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |