函数数组

#include<stdio.h>
#include<iostream>
using namespace std;

int f1(char *);
int f2(char *);
int f3(char *);
int f4(char *);
int f5(char *);

int (*ftk[5])(char *pStr)=
{
	f1,f2,f3,f4,f5,
};

int f1(char *pStr)
{
	cout<<pStr<<" "<<1<<endl;
	return 1;
}
int f2(char *pStr)
{
	cout<<pStr<<" "<<2<<endl;
	return 2;
}
int f3(char *pStr)
{
	cout<<pStr<<" "<<3<<endl;
	return 3;
}
int f4(char *pStr)
{
	cout<<pStr<<" "<<4<<endl;
	return 4;
}
int f5(char *pStr)
{
	cout<<pStr<<" "<<5<<endl;
	return 5;
}


int main()
{
	ftk[0]("111");
	ftk[1]("333");
	ftk[2]("555");
	ftk[3]("222");
	ftk[4]("444");

	return 0;
}



你可能感兴趣的:(函数数组)