函数数组

来源:互联网 发布:网络3无internet访问 编辑:程序博客网 时间:2024/05/19 13:56
#include "include.h"#include "stdio.h"#include <iostream>using namespace std;void handleCase1(int *key, int value){    cout<<"key="<<*key<<"--value="<<value<<endl;    *key = 0;    cout<<"handleCase1="<<*key<<endl;}void handleCase2(int *key, int value){    cout<<"key="<<*key<<"--value="<<value<<endl;    *key = 0;    cout<<"handleCase2="<<*key<<endl;}void handleCase3(int *key, int value){    cout<<"key="<<*key<<"--value="<<value<<endl;    *key = 0;    cout<<"handleCase3="<<*key<<endl;}void handleCase4(int *key, int value){    cout<<"key="<<*key<<"--value="<<value<<endl;    *key = 0;    cout<<"handleCase4="<<*key<<endl;}void (*af[])(int*, int)={    handleCase1,    handleCase2,    handleCase3,    handleCase4};
#include <iostream>#include "stdio.h"#include <iomanip>#include "include.h"using namespace std;int type = 0;int i = 0;int main(void){    for (i = 0; i < 4; i++)    {        type=10+i*10;        (*af[i])(&type, type);    }    cout<<"Done!"<<endl;    getchar();    getchar();}
原创粉丝点击