Hello, I was wondering what a second pair of eyes (or several) might have for opinions on this code? This program is supposed to store a user generated array, and functions which tell the highest, lowest, etc.
Mainly, I need help with the "set cell" part, which is supposed to allow the user to access any cell in the array
Thanks very much
#include <iostream>
#include "NumberArray.h"
using namespace std;
NumberArray::NumberArray(int s)
{
arrayPointer = new double [s]; // constructor
size = s;
}
NumberArray::~NumberArray()
{
delete [] arrayPointer;
array=NULL;
if(arrayPointer!=NULL) //destructor
{
cout << "inside destructor, just checking" << endl;
system ("pause");
}
NumberArray::void setCell(int i, double)
{
return arrayPointer[i];
}
NumberArray::int getCell(int i)
{
int i= arrayPointer[0];
for (int i = 0; i < elem; i++)
{
i=arrayPointer[count];
}
return arrayPointer[count];
}
NumberArray::highest()
{
double highest;
highest = arrayPointer[0];
for (int count = 1; count < elem; count++)
{
if (array[count] > highest)
highest = arrayPointer[count];
}
}
NumberArray::lowest()
{
double lowest;
lowest = arrayPointer[0];
for (int count = 1; count < elem; count++)
{
if (arrayPointer[count] < lowest)
lowest = arrayPointer[count];
}
}
NumberArray::double average()
{
float total=0;
float average;
for (int count = 0; count < elem; count++)
{
total += arrayPointer[count];
}
average = total/elem;
}