在C中函数不能出现在表达式的左边, 而在C++中由于有了引用类型而使其成为可能.
但在C++中,引用却是由指针来实现的,而指针又是C中的一个重要类型,为什么不能用指针来实现它呢?
这儿是我的一些粗劣的代码,望大家赐教!
#include <stdio.h>

static int i=0;

int * Increase()


{
i++;
return &i;
}

void (* Inc())()


{
i++;
return Inc;
}

int (*p)() = Inc;

int (* f(int j))()


{
i=j;
return Increase;
}

void main()


{
printf("\n");
Increase(); //i=1;
(*Increase()) ++; //i=3;
printf("%d\n",i);

(*Increase()) = 9; //i=9;
printf("%d\n",i);


/**//*-------------------*/

Inc();
printf("%d\n",i);

Inc()(); //但是p()();就错,想不明白
printf("%d\n",i);
//而且Inc()()()...都是错的,为什么啊?!


/**//*-------------------*/

f(9);
printf("%d\n",i);

f(9)();
printf("%d\n",i);

}