






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main topics in this course are object-orientation, objects and classes, overloading, inheritance, polymorphism, generic programming, exception handling, introduction to design patterns. This lecture includes: Print, Array, Object, Program, Oriented, Genetic, Increment, Decrement, Return, Main, Operator, Find, Array
Typology: Slides
1 / 11
This page cannot be seen from the preview
Don't miss anything!







template< typename T > template< typename T >
void printArray( T* array, int size ) void printArray( T* array, int size )
for ( int i = 0; i < size; i++ )
for ( int i = 0; i < size; i++ )
cout << array[ i ] <<
cout << array[ i ] << “
template< typename T >
template< typename T >
T* find( T* array, T* beyond,T* find( T* array, T* beyond,
const T& x ) {
const T& x ) {
T* p = array; T* p = array;
while ( p != beyond ) {
while ( p != beyond ) {
if ( *p == x )if ( *p == x )
return p;
return p;
p++;p++;
return return beyondbeyond;;
►
►
►
►
Increment operator (++)
Increment operator (++)
Dereference operator (*)
Dereference operator (*)
► ►
►
►
const Vector< T >& operator =( const Vector< T >& operator =(
const Vector< T >& ); const Vector< T >& );
T& operator ; T& operator ;
template< class T > template< class T >
const Vector& Vector::operator const Vector& Vector::operator
=( const Vector& right) {
=( const Vector& right) {
if ( this != &right ) {
if ( this != &right ) {
delete [] ptr;
delete [] ptr;
size = right.size; size = right.size;
template< class T >
template< class T >
T& Vector< T >::operator []( T& Vector< T >::operator [](
int index ) {
int index ) {
if ( index < 0 || index >= size ) { if ( index < 0 || index >= size ) {
cout <<
cout << “
Error: index out of
Error: index out of
range range\nn””;;
exit( 1 ); exit( 1 );
return ptr[index]; return ptr[index];
} } docsity.com