/*
*copyright (c) 2014, College of Computer Science, Yantai University
*all rights reserved.
* File Name: 16 weeks (pointer call function)
* Wangzhong
* Completion Date: 2014.12.11
* Version Number: v1.0
*
* Problem Description: Input as prompted, call function via pointer, output
* Input Description: 1.2.3.4
* Program output: Output all kinds of
#include <iostream>using namespace std;void eat (); void sleep (); void Hitdoudou (); void run (void (*f) ()); int Main () { int ichoice; do { cout<< "Please select (1-eat; 2-sleep; 3-dozen; others-back)"; cin>>ichoice; if (ichoice==1) run (eat); else if (ichoice==2) run (sleep); else if (ichoice==3) run (Hitdoudou); else if (ichoice==4) break ; } while (true); return 0;} void Eat () { cout<< "I eat ..." <<ENDL;} void Sleep () { cout<< "I sleep ..." <<ENDL;} void Hitdoudou () { cout<< "What can I do except play ..." <<ENDL;} void run (void (*f) ()) { f ();}
16 weeks (pointer call function)