泛型迭代器

    技术2024-11-11  22

    #include<iostream> using namespace std; template<class PTR, class DATA> PTR find(PTR start, PTR beyond , const DATA &x) { while(start != beyond && *start != x) ++start; return start; } int main() { int a[] = {1,2,3,4,5}; int *p = find<int*,int>(a,a+5,5); cout<<p<<endl; }

    最新回复(0)