Hi All,

Thank you for reading this and helping me! I am finishing off my program with a method that can compute Average Scores from a list of data. It's giving me an error that says "invalid use of member (did you forget the â&â ?)". Below is the code that I'm working on, the
error is the line with the Sum =. Please Help me figure out a way to sum up all the scores successfully!

int Team::AverageHome()
{
int Average = 0;
int Sum = 0;
int Number = 0;
int i;

        for( i = 0; i < NumGames; i++)
        {
                Sum = Sum + Games[i].GetHomeScore;
        }

        Average = Sum / i;

        return Average;
}

I don't see any syntax errors, assuming array Games is part of that class or a global variable. But the function won't work. Why? See line 5.

NumGames needs to be in scope in order for this to work, too.

Also, this:

Games.GetHomeScore

suggests an accessor function for a member variable of the object Games called Home Score based on the prefix Get before HomeScore. If that is indeed the case, then there needs to be a set a parenthesis () at the end of the above string. If GetHomeScore is a data member rather than a method of the class, then current syntax is correct, but variable name is misleading.

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.