64,643
社区成员
发帖
与我相关
我的任务
分享
struct a
{
int ture;
}
struct aa
{
int ture;
}
2个函数指针
tpyedef int (*p)(a a1);
tpyedef int (*pp)(aa a2);
#include<iostream>
using namespace std;
struct A
{
int a;
};
struct B
{
int b;
};
int FuncA( struct A sa )
{
return sa.a;
}
int FuncB( struct B stb)
{
return stb.b;
}
typedef int (*pA)( struct A sa );
typedef int (*pB)( struct B stb );
void TestA( pA p)
{
struct A sa;
sa.a = 10;
cout<<(*p)(sa)<<endl;
cout<<"TestA"<<endl;
}
void TestB( pB p)
{
cout<<"TestB"<<endl;
}
int main(int argc, char* argv[])
{
printf("Hello World!\n");
pA pa = FuncA;
pB pb = FuncB;
// TestA(pa);
// TestB( pb);
TestA( (pA)pb);
return 0;
}