Planet of NCCUCS
adobe photoshop 8.0 warez Adobe Premiere Pro CS5 can t reinstall adobe creative suite download adobe photoshop 8 0 cs Adobe Illustrator CS5 adobe premiere pro 1.5 serial key adobe acrobat reader 6.0 free Adobe Dreamweaver CS5 adobe course indesign software adobe photoshop free cursive fonts Adobe Photoshop CS5 Extended adobe photoshop elements 4 help sound adobe photoshop logos Adobe Creative Suite 5 Master Collection adobe creative suite torrents adobe photoshop and trial version Adobe Acrobat 9 Pro Extended adobe photoshop shape tools adobe photoshop free trial software Adobe Contribute CS5 wartz adobe acrobat adobe creative suite 2 academic Adobe Indesign CS5 adobe acrobat approval adobe premiere preview download Adobe Flash Catalyst CS5 602 acrobat adobe reader update adobe acrobat 7 reader update Adobe Flex Builder 3 Pro opening pps in adobe photoshop

什麼是 Function Pointer ?

作者:Anderson on 二月 4, 2009 Posted in RSS | | 觀看文章來源

函式指標變數(Function Pointer)就是可以存放函式起始位址的變數。

使用方式:


double (*fp)(double);

fp = square;

(*fp)(x); // 呼叫 square() 函式

以下轉載自 C程式語言教學

C語言允許陣列指標和函數三者混合宣告,以表達複雜的資料結構。對於要撰寫比較複雜的應用程式來說,了解這三者的關係是非常必要的。例如下面的變數x到底是甚麼?

char (*x[])();

要看懂這些東西,首先要查型別與運算裡有關優先權與結合序的表格,得到()[]是第一優先權左結合,而*是第二優先權右結合。在看變數宣告時,如同運算式的推演過程,必須遵守C程式語言對*()[]的優先權定義。接下來請讀者背誦下面的口訣

* 看見[]就說array[] of
* 看見*就說pointer to
* 看見變數後面的()就說function() returning

上述口訣配合*()[]的優先權,依序找出其執行的順序,每看到運算符號就把這幾句口訣念出來。因此變數的意義如下面範例

char *x; // x: a pointer to char
char x[3]; // x: an array[3] of char
char x(); // x: a function() returning char
char *x[3]; // x: an array[3] of pointer to char
char (*x)[3]; // x: a pointer to array[3] of char
char **x; // x: a pointer to pointer to char
char *x(); // x: a function() returning pointer to char
char *x()[3]; // x: a function() returning array[3] of pointer to char
char (*x[])(); // x: an array[] of pointer to function() returning char
char (*x())(); // x: a function() returning pointer to function() returning char
char (*(*x)[])(int, int); // x: a pointer to array[] of pointer to function(int,int) returning char

讀者在閱讀上面範例時,千萬不要把這些英文翻成中文! 英文文法是後面修飾前面,比中文更能確切表達文句的意義,因此在處理這些複雜宣告時,用英文去了解即可。

參考資料:

wiki : Function pointer

:
No comments for this entry yet...

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

最新文章

照片

R0012028R0012036R0013553R0013551R0013550R0013549R0013560R0013558R0013569R0013561R0013570R0013571R0013580R0013581R0013556R0013567R0013563R0013572R0011783R0012312