| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付买域名,送MP3、MP4
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY买空间,免费送域名(厦门中资源)
共有 245 人关注过本帖
标题:求助C++达人
收藏  订阅  推荐  打印 
welcomedz
Rank: 1
等级:新手上路
帖子:1
积分:110
注册:2008-6-7
求助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-6-7 08:14
stdlll
Rank: 1
等级:新手上路
帖子:10
积分:220
注册:2007-8-22

#include<iterator>
...
copy(v.begin(),v.end(),ostream_iterator(cout, "*");
2008-6-7 14:16
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.049797 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved