0

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;
}
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Lerner
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.