Number array cells

Hello, I was wondering if anyone has any ideas on what the syntax would be for getting the "cell". The program is supposed to have the ability to access any number from the user generated array, and display it.

Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#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)
    {
        cout << "inside destructor, just checking" << endl;
        system ("pause");
     }
        

NumberArray::void setCell(int, double)    

NumberArray::int getCell(int)

NumberArray::highest()
{
    double highest;
    highest = arrayPointer[0];
    for (int count = 1; count < elem; count++)
    {
        if (arrayPointer[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;
}
1
2
3
4
NumberArray::int getCell(int i)
{
    return arrayPointer[i];
}


It should be the same as every other array access in your code.
Topic archived. No new replies allowed.