所以我只是试图设置一个给定的数组索引值计数函数的结果。我已经阅读了有关计数函数的API,但在尝试将我的参数传递给所述计数函数时,我一直收到expression must have class type
错误。功能找到一个数组的开始和结束
这是到目前为止我的代码:
#include <iostream>
#include <limits>
#include <algorithm>
#include <array>
using namespace std;
int main(){
const size_t ARRAY_SIZE = 400;
int totalElements;
cout << "How many grades will you be entering?: ";
cin >> totalElements;
int gradesArray[ARRAY_SIZE];
for(int i = 0; i < totalElements; i++){
cout << "Please enter a grade: ";
cin >> gradesArray[i];
}
//to be incrimented with each count of a certain grade, from 0-5
int countOfGrades[6] = {0, 0, 0, 0, 0, 0};
countOfGrades[0] = count(gradesArray.begin(),gradesArray.end(),0);
return 0;
}//end of main
你在哪里定义了'count'? – 2014-11-03 00:46:02
http://www.cplusplus.com/reference/algorithm/count/ – FluffyKittens 2014-11-03 00:46:38
@ScottHunter:他没有:http://en.cppreference.com/w/cpp/algorithm/count – 2014-11-03 00:46:38