第一种类型:
int max(int a, int b)
{
if (a >= b)
{
return a;
}
else
{
return b;
}
}
typedef int(*getMax)(int, int);
getMax fn = max;
CCLog("max:%d", fn(1, 2));
CCLog("max:%d",(*fn)(1, 2));
第二种类型:
class A
{
public:
int max(int a, int b)
{
if (a >= b)
{
return a;
}
else
{
return b;
}
}
};
typedef int (A::*p)(int, int);
p func = &A::max;
A a;
CCLog("max:%d",(a.*func)(1, 3));