Exemple d’utilisation des listes comme paramètre d’une fonction

Author:

 list, list, iterator
Download


#include 
#include

using namespace std;

template < typename T > void
         affciher_contenu( const list< T > &liste )
{
   typename list< T >::const_iterator iter;

   for ( iter = liste.begin();
      iter != liste.end(); ++iter )
      cout << *iter << ' ';
}

int main()
{
   int tab[ 6 ] = { -1, -2, -3, -4, -5, -6 };
   list< int > coll(tab, tab+6);

   coll.push_back( 500 );
   coll.push_back( 400 );

   affciher_contenu( coll );

   cout << endl;
   return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *