typedef int (xxx)(int yyy);似乎定义了一个名为的函数指针xxx,它指向一个带整数参数的函数yyy.
但我无法理解语法......任何人都可以给出一个很好的解释吗?
我发现typedef int xxx(int yyy);仍然有效.他们之间有什么区别?
Pot*_*ter 15
这定义了一个函数类型,而不是函数指针类型.
模式typedef是它修改任何声明,使得它声明对象将具有的类型的别名,而不是声明对象.
这完全有效:
typedef int (xxx)(int yyy); // Note, yyy is just an unused identifier.
// The parens around xxx are also optional and unused.
xxx func; // Declare a function
int func( int arg ) { // Define the function
return arg;
}
Run Code Online (Sandbox Code Playgroud)
具体而言,C和C++语言不允许typedef在函数定义中使用名称作为整个类型.
| 归档时间: |
|
| 查看次数: |
1373 次 |
| 最近记录: |