// Pointer to functions

/*
C++ allows operations with pointers to functions. 
The typical use of this is for passing a function as an argument to another function, 
since these cannot be passed dereferenced. In order to declare a pointer to a function 
we have to declare it like the prototype of the function except that the name of the 
function is enclosed between parentheses () and an asterisk (*) is inserted before the name:
*/

#include "iostream.h"

void print_stuff(float data_to_ignore);
void print_message(float list_this_data);
void print_float(float data_to_print);
void (*function_pointer)(float);

int main()
{
const float pi     = 3.14159;
      float two_pi = 2.0 * pi;

   print_stuff(pi);
   function_pointer = print_stuff;
   function_pointer(pi);

   function_pointer = print_message;
   function_pointer(two_pi);
   function_pointer(13.0);

   function_pointer = print_float;
   function_pointer(pi);
   print_float(pi);
 
   std::cin.get();
   return (0);
}

void print_stuff(float data_to_ignore)
{
   printf("This is the print stuff function.\n");
}

void print_message(float list_this_data)
{
   printf("The data to be listed is %f\n", list_this_data);
}

void print_float(float data_to_print)
{
   printf("The data to be printed is %f\n", data_to_print);
}



