














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















const int* find( const int* array, int _size, int x ) { const int* p = array; for (int i = 0; i < _size; i++) { if ( *p == x ) return p; p++; } return 0;
}
template< typename T >
T* find( T* array,int _size,
const T& x ) { T* p = array; for (int i = 0; i < _size; i++) { if ( *p == x ) return p; p++; } return 0;
}
template< typename T >
T* find( T* array, T* beyond,
const T& x ) { T* p = array; while ( p != beyond ) { if ( *p == x ) return p; p++; } return beyond;
}
template< typename T >
T* find( T* array, T* beyond,
const T& x ) { T* p = array; while ( p != beyond && *p != x ) p++; return p;
}
template< typename P, typename T >
P find( P start, P beyond, const T& x ) { while ( start != beyond && *start != x ) start++; return start;
}
int main() {
int iArray[5]; iArray[0] = 15; iArray[1] = 7; iArray[2] = 987; … int* found; found = find(iArray, iArray + 5, 7); return 0;
}
template< class T >
class Vector {
private:
int size; T* ptr;
public:
Vector
template< class T >
Vector
size = s; if ( size != 0 ) ptr = new T[size]; else ptr = 0;
}
template< class T >
Vector
const Vector
}
template< class T >
const Vector
=( const Vector
if ( size != 0 ) { ptr = new T[size]; for(int i = 0; i < size;i++) ptr[i] = right.ptr[i]; } else ptr = 0; } return *this;
}