一道C++问题,请高手帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/19 07:15:48
#include <iostream>
#include <vector>
int main ()
{using std::vector;
vector<int> s;
int q=10;
while(q>0)
s.push_back(q--);

std::cout << *s << std::endl ;
}
上面这道程序 哪里错了 ? 为什么编译器就提示说我错了呢

提示内容为 no match for 'operator*' in '*s'

这是为什么???

请高手帮助我 谢谢了!

改成 s[0] 就好了
如果你想输出全部元素,可用
#include <iterator>
#include <algorithm>

copy( s.begin(), s.end(), ostream_iterator<int>(cout, "\n") );

回楼下,就这么多,你的编译器过时了吧。

楼上的,说具体点行不?
copy( s.begin(), s.end(), ostream_iterator<int>(cout, "\n") );
编译出错!还要加什么地方码?