More Related Content
Similar to Class array (20)
Class array
- 1. class Array
{
private:
int size;
int *pointer;
public:
Array()
{
size=0;
pointer=NULL;
}
void load()
{
cout <<"Enter the number of integers in the array.nn";
cin >>size;
pointer = new int[size];
int i;
for (i=0; i< size; i++)
{
cout <<"Enter interger # " << i+1 <<"n";
cin >>*(pointer+i);
}
}//end of load
void print()
{
int i =0;
cout <<"The array contains " <<size << "integers.nn";
cout <<"They are:n";
while (i < size)
{
cout <<i+1<<")t"<<*(pointer+i)<<endl;
i++;
}//end of loop
}
~Array() //destructor to delete the array
{
delete []pointer;
}
};
void main (void)
{
Array array1;
array1.load();
array1.print();
array1.~Array();