Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
138 views
in Technique[技术] by (71.8m points)

c++ - what does this mean char (*(*a[4])())[5]?

Hi I came across the question in "Test your skills in c++".

Please let me know what does it mean with an example?

Edited Section: Sorry for the extra parenthesis, edited & removed.

char (*(*a[4])())[5]
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Following the spiral rule (as linked to by chris), and starting with the identifier:

a

...is...

a[4]

...an array of 4...

*a[4]

...pointers to...

(*a[4])()

...a function taking no parameters...

*(*a[4])()

...returning pointer to...

(*(*a[4])())[5]

...an array of five...

char (*(*a[4])())[5]

...chars.

Sidenote: Go give the architect who came up with this a good dressing-down, then find the programmer who wrote this code without a comment explaining it and give him a good dressing-down. In case this was given to you as a homework, tell your teacher that he should have instructed you on how to use cdecl instead, or how to design code in a way that it doesn't look like madman scrawlings, instead of wasting your time with this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...