Complicated Declarations
来源:互联网 发布:linux ftp安装 编辑:程序博客网 时间:2024/05/01 11:05
对识别C/C++中复杂的声明,Thinking in C++中介绍了一种简单的方法,right-left-right,即以变量为中心,向右走,一直到碰到右括号或不能再往右走,再往左走步,碰到左括号,再向右走。。。
如对于void * fun(void),可以翻译为fun is a function that requires no argument and returns pointer to void。而void (* fun)(int),则可以理解为fun is a pointer to function that requires int argument and returns void。
值得注意的是,对于像function这样的情况,必须先说argument,再说return value,两者都不可缺。例如,
理解为,set_handler is a function that requires ... argument and returns pointer to function that requires no argument and returns pointer to void。
碰到具体的符号的读法如下:
void * (*set_handler(void (*f)))();
碰到具体的符号的读法如下:
id 'id' is a
* pointer to
(---) funciont that requires---argument(s) and returns
[---] array of
type type
* pointer to
(---) funciont that requires---argument(s) and returns
[---] array of
type type
Thinking in C++中也提到,这种方法对大部分声明有效,里面没有提到无效的声明(我也想不到),可能是其他一些比较变态的声明。而The C programming language则从C的语法角度解释了复杂表达式的解读方法。
dcl: optional *'s direct-dcl
direct-dcl: name
(dcl)
direct-dcl()
direct-dcl[optional size]
direct-dcl: name
(dcl)
direct-dcl()
direct-dcl[optional size]
用top down的方法,即可很容易的出上面的结论了。具体请看相关章节The C Programming Language 5.12
- Complicated Declarations
- complicated declarations
- 复杂的声明(Complicated Declarations)
- declarations
- Complicated 歌词
- Complicated disputes
- 10.3 Declarations
- Forward Declarations
- Variable Declarations
- Method Declarations
- JOJ 1106 Complicated Expressions
- Microsoft make things complicated
- Complicated Expressions--POJ--1400
- Oracle complicated group
- [POJ] 1400 -> Complicated Expressions
- POJ 1400 Complicated Expressions
- A. Complicated GCD
- 664A - Complicated GCD
- Encoding Filter实现
- connect by prior start with 总结
- zoj-1319-Black Box
- zoj-1010-Area
- Web测试方法
- Complicated Declarations
- 放假第三周总结
- 关于23种设计模式得有趣见解
- 轻型数据库SQLite结合PHP的开发
- 趣味数学与C++
- 最小二乘法
- Reading a paper of Texture'05 submission #050 "Hole Filling Throng Photomontage"
- Java有关下载提示
- MyEclipse起步