Need help to fix errors, I know int a[] should be specified but not sure how to.

#include <iostream>
using namespace std;

class TWO
{
private: int age[5];
public:
//read data into array
void ReadData(int age[], int n);
//member to return the average of data in array age of object p
friend  int FindAverage(TWO p);
//member to find and return the max and min age
void FindMaxMin(int &maxAge, int& minAge, int age[], int n);
//display ages > age average
void DisplayAboveAverage(int ageAve, int age[], int n);
//display the max and min ages
void DisplayMaxMinAge(int maxAge, int minAge, int age[], int n);
//release all memory used by objects
~TWO() {}
};

int main()
{
int a[]; int n;
int maxAge;
int minAge;
int ageAve;
TWO x;

x.ReadData(a[],n);
FindAverage(x);
x.FindMaxMin(maxAge,minAge);
x.DisplayAboveAverage(ageAve);
x.DisplayMaxMinAge(maxAge, minAge);

return 0;
}

// class functions
void TWO :: ReadData(int x[], int n)
{
for(int i = 0; i < 5; ++i)
    {   cout << "Enter 5 ages: "; 
        cin >> x[i];
    }
}
void FindAverage(TWO p, int x[], int n)
{   int total = 0;
    for(int i = 0; i < 5; ++i)
    {   
        total += x[i];
    }

}
void TWO :: FindMaxMin(int &maxAge, int& minAge, int x[], int n)
{

    int maxAge = x[0];
    for(int i = 0; i < 5; ++i)
    if(maxAge < x[i])
        maxAge = x[1];
    int minAge = x[0];
    for(int i = 0; i < 5; ++i)
    if(minAge > x[i])
        minAge =  x[3];
}
void TWO :: DisplayAboveAverage(int ageAve, int x[], int n)
{
    int total = 0;
    for(int i = 0; i < 5; ++i)
    {   
        total += x[i];
        if(ageAve > total)
            cout << 
    }

}
void TWO :: DisplayMaxMinAge(int maxAge, int minAge, int x[], int n)
{
    int maxAge = x[0];
    for(int i = 0; i < 5; ++i)
    if(maxAge < x[i])
        cout << "Maximum age is " << x[1];
    int minAge = x[0];
    for(int i = 0; i < 5; ++i)
    if(minAge > x[i])
        cout <<  x[3];
}

Output should look like this:

Enter 5 ages: 22 27 19 17 25
  Ages above average: 27 25
  Maximum age is 25
  Minimum age is 17

line 74,

cout << 

is this supposed to be like this?

You need to show us the errors you are getting. What kreiger said is correct - that is an error. Also, on line 24 you are declaring a[] as an array with no size. This won't work, and is a situation where declaring a global or static constant for the age array size would be appropriate, such as:

static const size_t NUM_AGES = 5;

and then use that when you declare the age[] array and a[] arrays. In such a case, line 6 would be int age[NUM_AGES] and line 24 would be int a[NUM_AGES] and your loops would instead of for (int i = 0; i < 5; i++) or whatever, would be for (int i = 0; i < NUM_AGES; i++). That way, if you need to change the number of elements, you just have to alter the const value definition of NUM_AGES.

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.