#include "stdio.h" inline int square ( int a ) { return a * a ; } inline int cube ( int a ) { return a * a * a ; } inline int fourthpower ( int a ) { return a * a * a * a ; } inline int squarepluscube ( int a ) { return square ( a ) + cube ( a ) ; } inline int squarepluscubeplusfourthpower ( int a ) { return squarepluscube ( a ) + fourthpower ( a ) ; } int ( * functionpointers [ 5 ] ) ( int ) ; /* the above line declares an array called functionpointers that has three ( 3 ) elements which are all pointers ( * ) to functions which take a single integer as parameter ( int ) and return nothing ( void ) and do not modify the contents of the class in anyway ( const ) */ void executefunction ( int functionnumber, int inputforfunction ) { printf ( "%d\n", ( * functionpointers [ functionnumber ] ) ( inputforfunction ) ) ; // this line calls the function which is pointed ( * ) to by the functionnumber-th element of the functionpointers array which is a member of the object pointed to by the current object pointer ( this ) and passes the function the value of the variable inputforfunction as a parameter } int main ( void ) { functionpointers [ 0 ] = & square ; functionpointers [ 1 ] = & cube ; functionpointers [ 2 ] = & fourthpower ; functionpointers [ 3 ] = & squarepluscube ; functionpointers [ 4 ] = & squarepluscubeplusfourthpower ; int count ; for ( count = 0; count < 5; count ++ ) executefunction ( count, 2 ) ; }