再來(lái)看一個(gè)例子:
int *( *( *arr[5])())();
閱讀步驟:
1. 從變量名開(kāi)始 -------------------------------------------- arr
2. 往右看,發(fā)現(xiàn)是一個(gè)數(shù)組 ---------------------------------- 一個(gè)5元素的數(shù)組
3. 向左看,發(fā)現(xiàn)一個(gè)* --------------------------------------- 指針
4. 跳出括號(hào),向右看,發(fā)現(xiàn)() -------------------------------- 不帶參數(shù)的函數(shù)
5. 向左看,碰到* ------------------------------------------- (函數(shù))返回一個(gè)指針
6. 跳出括號(hào),向右發(fā)現(xiàn)() ------------------------------------ 不帶參數(shù)的函數(shù)
7. 向左,發(fā)現(xiàn)* --------------------------------------------- (函數(shù))返回一個(gè)指針
8. 繼續(xù)向左,發(fā)現(xiàn)int --------------------------------------- int類型
總結(jié):??
還有更多的例子:
float ( * ( *b()) [] )(); // b is a function that returns a
// pointer to an array of pointers
// to functions returning floats.
void * ( *c) ( char, int (*)()); // c is a pointer to a function that takes
// two parameters:
// a char and a pointer to a
// function that takes no
// parameters and returns
// an int
// and returns a pointer to void.
void ** (*d) (int &,
char **(*)(char *, char **)); // d is a pointer to a function that takes
// two parameters:
// a reference to an int and a pointer
// to a function that takes two parameters:
// a pointer to a char and a pointer
// to a pointer to a char
// and returns a pointer to a pointer
// to a char
// and returns a pointer to a pointer to void
float ( * ( * e[10])
(int &) ) [5]; // e is an array of 10 pointers to
// functions that take a single
// reference to an int as an argument
// and return pointers to
// an array of 5 floats.
計(jì)算機(jī)等級(jí)考試二級(jí)C++各章考點(diǎn)內(nèi)容摘要
希望與更多計(jì)算機(jī)等級(jí)考試的網(wǎng)友交流,請(qǐng)進(jìn)入計(jì)算機(jī)等級(jí)考試論壇
更多信息請(qǐng)?jiān)L問(wèn):考試吧計(jì)算機(jī)等級(jí)考試欄目
北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內(nèi)蒙古 |