标题:迭代器问题
只看楼主
q1826050194
Rank: 2
等 级:论坛游民
帖 子:67
专家分:19
注 册:2011-3-7
结帖率:77.78%
已结贴  问题点数:20 回复次数:2 
迭代器问题
#include<algorithm>
#include<iostream>
#include<iterator>

template<typename Iter>
void print(Iter first,Iter last,const char* nm="", const char* seq="\n",std::ostream& os=std::cout){
    if(nm!=0&&nm!='\0')
    os<<nm<<":"<<seq;
    typedef typename iterator_traits<Iter>::value_type T;
    copy(first,last,ostream_iterator<T>(cout,seq));
    os<<std::endl;
}

--------------------配置: mingw5 - LIB Release, 编译器类型: MinGW--------------------

检查文件依赖性...
正在编译 C:\Users\zjy\Documents\C-Free\Temp\未命名15.cpp...
[Error] C:\Users\zjy\Documents\C-Free\Temp\未命名15.cpp:9: error: expected nested-name-specifier before "iterator_traits"
[Error] C:\Users\zjy\Documents\C-Free\Temp\未命名15.cpp:9: error: expected initializer before '<' token
[Error] C:\Users\zjy\Documents\C-Free\Temp\未命名15.cpp:10: error: `ostream_iterator' was not declared in this scope
[Error] C:\Users\zjy\Documents\C-Free\Temp\未命名15.cpp:10: error: `T' was not declared in this scope
[Error] C:\Users\zjy\Documents\C-Free\Temp\未命名15.cpp:10: error: `cout' was not declared in this scope
构建中止 未命名15: 5 个错误

求帮助...
搜索更多相关主题的帖子: void 检查 Documents include 编译器 
2012-07-10 20:09
ZRTan
Rank: 1
等 级:新手上路
帖 子:2
专家分:1
注 册:2012-7-11
得分:0 
惨了,表示看不懂~!
2012-07-11 00:06
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:20 
稀里糊涂的人不适合学编程,因为那需要严谨

template<typename Iter>
void print( Iter first, Iter last, const char* nm="", const char* seq="\n", std::ostream& os=std::cout )
{
    if( nm!=0 && nm[0]!='\0' )
        os << nm << ":" << seq;

    typedef typename std::iterator_traits<Iter>::value_type T;
    copy( first, last, std::ostream_iterator<T>(os,seq));
    os << std::endl;
}
2012-07-11 12:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-373119-1-1.html




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

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