在C中,f不是"没有参数",而是"任何参数"*.说int f(void)声明"没有参数".
这与C++不同.值得注意的是,C具有功能"声明"和功能"原型"的单独概念:
int f(); /* declaration -- f is still a mystery */
int f(int, double); /* prototype -- now we know how to call f */
int f(int n, double c) { return -1; } /* defintion -- now we can link */
Run Code Online (Sandbox Code Playgroud)
*)正如我在评论中所说,"任何参数"仅限于不受默认促销的类型(与默认促销发生在可变参数上的方式相同).也就是说,float中,所有的口味char和short int,而且...,是不是在实际的函数签名允许.
| 归档时间: |
|
| 查看次数: |
292 次 |
| 最近记录: |