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;
}

Does this code actually compile? Your functions should like this:

returnType ClassName::FunctionName (Paramaters)
{
    // function code goes here
}

As far as your set cell function is concerned you could do it like

void NumberArray::setCell(int index, double value)
{
    arrayPointer[i] = value;
}

You should also make sure that you are accessing a valid location in the array but I'll leave that for you to code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.