| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 939 人关注过本帖
标题:求助C++达人
只看楼主 加入收藏
welcomedz
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-7
收藏
 问题点数:0 回复次数:1 
求助C++达人
#include <vector>

#include <iostream>

#include <algorithm>

using namespace std;

main(){

 int a[5] = {1,2,3,4,5};

 CMyostream_iterator<int> output(cout,"*");

 vector<int> v(a,a+5);

 copy(v.begin(),v.end(),output);

}
  

程序的输出结果是:

1*2*3*4*5*

 注意,编写CMyostream_iterator时不能使用 ostream_iterator

参考 copy 的help

copy

template<class InIt, class OutIt> OutIt copy(InIt first, InIt last, OutIt x);

The template function evaluates *(x + N) = *(first + N)) once for each N in the range [0, last - first), for strictly increasing values of N beginning with the lowest value. It then returns x + N. If x and first designate regions of storage, x must not be in the range [first, last]

请问,哪位前辈能给个参考。不胜感激
搜索更多相关主题的帖子: iterator include output first The 
2008-06-07 08:14
stdlll
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-8-22
收藏
得分:0 
#include<iterator>
...
copy(v.begin(),v.end(),ostream_iterator(cout, "*");
2008-06-07 14:16
快速回复:求助C++达人
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013828 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved