|
楼主 |
发表于 2003-8-1 11:06:56
|
显示全部楼层
最初由 高原之狼 发表
Quoting ``C: A Reference Manual'' (4th edition) by S. P. Harbison and G. L. Steele Jr., p. 147:
<QUOTE>
In ISO C and some other implementations, an expression of type ``pointer to function'' can be used in a function call without an explicit dereferencing; in that case, the call (*fp)(j,k) in the example above can be written as fp(j,k).
</QUOTE>
However, in my opnion, (*p)() looks more correct than p(). After all, p is a variable of type ``pointer to function''.
I don't think so.
we can take " regular pointer " as analogy.
In the following code segment:
- int a[] = {1, 2, 3};
- int * p = a;
- printf("%d",p[1]);[color=red]/* Note: we just use [color=blue]'p'[/color], but not [color=blue]'*p'[/color] */[/color]
复制代码
In this example, a is a const pointer, so it can be followed by the operator"[]". By analogy, p can also be followed by the operator "[]".
So we can draw the conclusion: the operand of "[]" is "pointer".
By analogy, the oprand of "()" should be "pointer of function". |
|