C++ 複雜聲明

來源:互聯網
上載者:User
/*功能,C++ 複雜聲明() [] 的優先順序高於 *。更多參看以下資料:《C程式設計語言V2cn》p105,5.12,複雜聲明。http://blog.csdn.net/wangweixaut061/article/details/6549768部落格,http://blog.csdn.net/shunqiziranhao007/article/details/8709168日期,2013年3月23日*/#include <iostream>using std::cout; using std::endl;#define P1 cout << endl;#define P2(X) cout << X;#define P3(X) cout << X << endl;template<typename T> void ok(T) {}char* f1(){P3("char* f1()")return 0;}char* f2(){P3("char* f2()")return 0;}typedef char* (*f_t)();f_t f3(){P3("f_t f3()")return f1;}f_t f4(){P3("f_t f4()")return f2;}int main(){char *(*(*a[])())() = {f3, f4};a[0]()();a[1]()();int i;int *pi;int **ppi;int ai[10];int *api[10];int (*pai)[10];// A pointer to a function a that takes an integer argument and returns// an integerint (*fi)(int);// An array of 10 pointers to functions that take an integer argument// and return an integer  int (*fai[10])(int);}/*$ ./declare.exe f_t f3()char* f1()f_t f4()char* f2()*/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.