|
|
发表于 2006-10-14 15:03:16
|
显示全部楼层
int NumberOf100Scores(0)=count (Scores.begin(), Scores.end(), 100);
the form you were using is obsolete and removed from stl
Post by spirit_cg
从精华区的帖子里拿来学习的,源程序如下:
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main () {
list<int> Scores;
Scores.push_back(100); Scores.push_back(80);
Scores.push_back(45); Scores.push_back(75);
Scores.push_back(99); Scores.push_back(100);
int NumberOf100Scores(0);
count (Scores.begin(), Scores.end(), 100, NumberOf100Scores);
cout << "There were " << NumberOf100Scores << " scores of 100" << endl;
return 0;
}
编译出现的错误如下:
spirit@freefly:~/program$ g++ stlTest.cpp -o stlTest
stlTest.cpp: In function ‘int main()’:
stlTest.cpp:14: 错误: 对 ‘count(std::_List_iterator<int>, std::_List_iterator<int>, int, int&)’ 的调用没有匹配的函数
请问大家这是怎么回事?好像调用STL里的函数没有成功,谢谢大家帮助解决!^_^ |
|