这是不断出现错误的功能:
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;
答案 0 :(得分:0)
在函数声明中,您使用intArrayTable *table
。这意味着参数table
是指向intArrayTable
的指针。因此,必须将mean += table[i]/maxStud;
行替换为mean += (*table)[i]/maxStud;