#include<iostream>
#include<string>
#include<map>
using namespace std;
int a()
{
cout<<"fuck A"<<endl;
return 0;
}
int b()
{
cout<<"fuck B"<<endl;
return 0;
}
void c(int a = 0)
{
cout<<"fuck C"<<a<<endl;
}
void d(int a = 0,int b = 1)
{
cout<<"fuck D"<<a<<b<<endl;
}
typedef void * f;
typedef int (*ff)();
typedef void (*fff)(int a);
typedef void (*ffff)(int a,int b);
int main()
{
map<string,f> vv;
string str;
str = "a";
vv[str] = a;
str = "b";
vv[str] = b;
str = "c";
vv[str] = c;
str ="d";
vv[str] = d;
str = "a";
(*((ff)vv[str]))();
map<string,f>::iterator ite;
ite = vv.find("a");
(*(ff)(ite->second))();
ite =vv.find("c");
(*(fff)(ite->second))(3);
ite =vv.find("d");
(*(ffff)(ite->second))(4,4);
return 0;
}
函数指针
最新推荐文章于 2024-03-11 05:00:00 发布