C++ std::查找don';我不想使用自己的类包装器 #包括 #包括 使用名称空间std; 模板 迭代器查找(迭代器优先、迭代器最后、常量T&v) { while(first!=last&&*first!=v) ++第一,; 先返回; } 结构int_节点 { int-val; int_节点*下一步; }; 模板 结构节点 { 节点*ptr; node_wrap(node*p=NULL):ptr(p){} 节点和运算符*()常量{return*ptr;} 节点*运算符->()常量{return ptr;} node_wrap&operator++(){ptr=ptr->next;返回*this;} node_wrap&operator++(int){node_wrap tmp=*this;++this;return tmp;} 布尔运算符==(const node_wrap&i)const{return ptr==i.ptr;} 布尔运算符!=(const node_wrap&i)const{return ptr!=i.ptr;} }; 布尔运算符==(常量int_节点和节点,int n) { return node.val==n; } 接线员=(常数int_节点和节点,int n) { 返回node.val!=n; } int main() { int_node*nod[10]; 对于(int i=0;i b; nod[i]=新的内部节点; nod[i]>val=b; 如果(i==0) nod[i]->next=NULL; 其他的 nod[i]->next=nod[--j]; } INTA; cout>a; 第一个节点(nod[9]); node_wrap search=find_my(首先,node_wrap(),a); if(search!=node_wrap()) cout

C++ std::查找don';我不想使用自己的类包装器 #包括 #包括 使用名称空间std; 模板 迭代器查找(迭代器优先、迭代器最后、常量T&v) { while(first!=last&&*first!=v) ++第一,; 先返回; } 结构int_节点 { int-val; int_节点*下一步; }; 模板 结构节点 { 节点*ptr; node_wrap(node*p=NULL):ptr(p){} 节点和运算符*()常量{return*ptr;} 节点*运算符->()常量{return ptr;} node_wrap&operator++(){ptr=ptr->next;返回*this;} node_wrap&operator++(int){node_wrap tmp=*this;++this;return tmp;} 布尔运算符==(const node_wrap&i)const{return ptr==i.ptr;} 布尔运算符!=(const node_wrap&i)const{return ptr!=i.ptr;} }; 布尔运算符==(常量int_节点和节点,int n) { return node.val==n; } 接线员=(常数int_节点和节点,int n) { 返回node.val!=n; } int main() { int_node*nod[10]; 对于(int i=0;i b; nod[i]=新的内部节点; nod[i]>val=b; 如果(i==0) nod[i]->next=NULL; 其他的 nod[i]->next=nod[--j]; } INTA; cout>a; 第一个节点(nod[9]); node_wrap search=find_my(首先,node_wrap(),a); if(search!=node_wrap()) cout,c++,iterator,C++,Iterator,std::find需要有关您的类型的更多信息才能正确工作。特别是,需要使用迭代器: error C2868: 'std::iterator_traits<_Iter>::difference_type' : illegal syntax for using- declaration; expected qualified-name 1> with 1> [ 1> _Iter=node_wrap

std::find
需要有关您的类型的更多信息才能正确工作。特别是,需要使用迭代器:

error C2868: 'std::iterator_traits<_Iter>::difference_type' : 
illegal syntax for using-      declaration;
expected qualified-name
1>          with
1>          [
1>              _Iter=node_wrap<int_node>
1>          ]
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(368): 
error C2039: 'pointer' : is not a member of 'node_wrap<Node>'
1>          with
1>          [
1>              Node=int_node
1>          ]
模板
结构节点
{
typedef void difference_type;//您应该使用另一种差异类型
类型定义节点值\u类型;
typedef节点*指针;
typedef节点&参考;
typedef std::forward_iterator_tag iterator_category;
// ...
};
“不想使用”。这意味着什么?Comiler错误、运行时错误、意外结果?请澄清并正确缩进代码。
error C2868: 'std::iterator_traits<_Iter>::difference_type' : 
illegal syntax for using-      declaration;
expected qualified-name
1>          with
1>          [
1>              _Iter=node_wrap<int_node>
1>          ]
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(368): 
error C2039: 'pointer' : is not a member of 'node_wrap<Node>'
1>          with
1>          [
1>              Node=int_node
1>          ]
template<class Node>
struct node_wrap
{
    typedef void difference_type; // you should use another difference type
    typedef Node value_type;
    typedef Node* pointer;
    typedef Node& reference;
    typedef std::forward_iterator_tag  iterator_category;

    // ...
};