/*Orion Lawlor's Simple C++ Examples, olawlor@acm.org
Shows how to use pointer-to-functions.
*/
#include <iostream>

void A(int x) {std::cout<<"A("<<x<<")"<<std::endl;}
void B(int x) {std::cout<<"B("<<x<<")"<<std::endl;}

//Declares a type named "fn_t"
typedef void (* fn_t) (int x);

int main()
{
	fn_t func=A;//func points to A
	
	//Call function pointer func--
	//  looks like regular function call
	func(3);
	
	return 0;
}

/*<@>
<@> ******** Program output: ********
<@> A(3)
<@> */
