在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 次 |
最近记录: |