I'm doing exercises out of a book for self-learning purposes, and one of the exercises is:

Design, implement and test class Average. An object of type Average should accept values that are put into it. At any point in time it should be possible to retrieve their cumulative arithmetic average.

Well, I think (or, at least, hope) that my math is right in the sense that this is what I would have to do in order to complete the calculations, but my compiler (Dev-C++) is giving me a ton of errors saying "invalid types double[int] for array subscript". I know this is referring to the loops where I have numbers[x], but it just gives me the error "invalid types double[double] for array subscript" when I try changing x to the type double. I really have no clue as to how to get around this:

Code:#include <iostream> using std::cout; using std::cin; class Average { public: double numbers; int x; int numsmone; Average (int nums) { numsmone = nums - 1; for (x = 0; x < nums; ++x) { if (x == 0) cout << "Enter the 1st number: "; else if (x == 1) cout << "Enter the 2nd number: "; else if (x == 2) cout << "Enter the 3rd number: "; else cout << "Enter the " << x << "th number: "; cin >> numbers[x]; } } double CalculateMean () { double mean; for (x = 0; x < numsmone; ++x) mean = numbers[x] + numbers[x+1]; mean = mean / (numsmone + 1) return mean; } }; int main () { int nums; cout << "Enter the number of numbers you wish to average: "; cin >> nums; Average Avgone(nums); cout << "The mean is " << Avgone::CalculateMean; cin.get(); return 0; }