STL problem sets


Here are some problem sets to practise your STL skills:


Problem sets involving std::bind()


The problems are like this:
  • use std::bind() to simplify this code:
    int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    int sz = sizeof(arr)/sizeof(int);

    int total = 0;
    for( int i=0; i<sz; i++ )
    {
        add_if_number_is_odd( arr[i], &total );
    }

Problem 1: calling a C-function.   (solution).
Problem 2: calling a member function.   (solution)
Problem 3: calling a member function with arguments.   (solution)
Problem 4: calling a member function with arguments.   (solution)
Problem 5: calling own member function.   (solution)


Problems sets with function objects


Try to rewrite the following using function objects

Problem 1: calling a C-function.   (solution).
Problem 2: calling a member function.   (solution)
Problem 3: calling a member function with arguments.   (solution)
Problem 4: calling a member function with arguments.   (solution)
Problem 5: calling own member function.   (solution)



No comments:

Post a Comment