第16周 项目3 用函数指针调用函数
2014-12-16 20:38
218 查看
问题及代码:
/*。 *Copyright(c)2014,烟台大学计算机学院 *All right reserved, *文件名:test.cpp *作者:liu_feng_zi_ *完成日期:2014年12月16日 *版本号:v1.0 * 问题描述:用函数指针调用函数 *输入描述: *程序输出: */ #include <iostream> using namespace std; void eat(); void sleep(); void hitdoudou(); void run(void (*f)()); int main() { int iChoice; do { cout<<"请选择(1-吃;2-睡;3-打;其他-退)"; cin>>iChoice; if(iChoice==1) run(eat); else if(iChoice==2) run(sleep); else if(iChoice==3) run(hitdoudou); else break; } while(true); return 0; } void eat() { cout<<"我吃吃----"<<endl; } void sleep() { cout<<"我睡睡睡----"<<endl; } void hitdoudou() { cout<<"我打打打----"<<endl; } void run(void (*f)()) { f(); }运行结果:
相关文章推荐
- 第16周项目3 用函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第16周 项目3-用函数指针调用函数
- 第16周【项目 3-用函数指针调用函数】
- 第16周项目3--用函数指针调用函数(吃饭,睡觉,打豆豆)
- 第16周项目3函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第16周 项目3-用函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第16周项目3—用函数指针调用函数
- 2014秋C++第16周 项目3参考 用函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第16周项目3 用函数指针调用函数
- 第16周项目3 用函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第16周项目3-用函数指针调用函数(吃饭、睡觉、打豆豆)
- 第16周上机实践项目3——用函数指针调用函数
- 第16周项目3-用函数指针调用函数
- 第十六周 项目三--用函数指针调用函数