我不知道我的功能出了什么问题。一些帮助将不胜感激

时间:2019-10-03 02:09:41

标签: c++

这是不断出现错误的功能:

void displaySmallestLargestMean (intArrayTable *table, int r, int c, int maxStud)
{
  int smallest, largest;
  double mean;
  smallest = 1;
  largest = maxStud;
  for (int i = 0; i < maxStud; i++)
  {
      mean += table[i]/maxStud;
  }
  cout << "This is your Smallest Value: " << smallest << endl;
  cout << "              Largest Value: " << largest << endl;
  cout << "         Mean of the Values: " << mean << endl;
}

这是我的错误信息:

mainA5-255.cpp: In function ‘void displaySmallestLargestMean(int**, int, int, int)’:
mainA5-255.cpp:88:21: error: invalid operands of types ‘intArrayTable {aka int*}’ and ‘int’ to binary ‘operator/’
     mean += table[i]/maxStud;

1 个答案:

答案 0 :(得分:0)

在函数声明中,您使用intArrayTable *table。这意味着参数table是指向intArrayTable的指针。因此,必须将mean += table[i]/maxStud;行替换为mean += (*table)[i]/maxStud;