所以我只是試圖設置一個給定的數組索引值計數函數的結果。我已經閱讀了有關計數函數的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