编译报错
程序代码:
#include <iostream> #include <vector> #include <list> #include <algorithm> #include <functional> using namespace std; int main() { int A[] = {1, 4, 3, 2, 5}; int N = sizeof(A) / sizeof(int); vector<int> coll(A, A + N); ostream_iterator<int> output(cout, " ");// 编译时提示错误“ostream_iterator”: 未声明的标识符 cout << "Vector coll contains"; copy(coll.begin(), coll.end(), output); sort(coll.begin(), coll.end()); cout << "nAfter sorted in ascending order coll contains"; copy(coll.begin(), coll.end(), output); sort(coll.begin(), coll.end(), greater<int>()); cout << "\nAfter sorted in descending ordercoll contains"; copy(coll.begin(), coll.end(), output); cout << endl; return 0; }
在window7下 用visual studio2012编译的结果。大家帮我看看怎么改呢,谢谢!