typedef int (*PFunc)(int);
去掉 typedef ,得到正常变量声明=> int (*PFunc)(int);
变量 PFunc 的类型为一个函数指针,指向的返回值类型为 int,参数类型为 int 的函数
原型;
"typedef int (*PFunc)(int)"中 PFunc是函数指针类型(该指针类型指向返回值类型为
int,参数类型为 int 的函数)的一个 typedef-name。
PFunc fptr; <=> fptr 是一个 pointer to function with one int parameter, returning int
#include "iostream"
using namespace std;
int add(int a,int b){
return (a+b);
}
typedef int (* func)(int ,int ) ;
void main(){
func f = add;
int n = f(1,2);
cout << n << endl;
}
typedef int* Func(int);
去掉 typedef ,得到正常变量声明=> int* Func(int);
变量 Func 的类型为一个函数标识符,该函数返回值类型为 int*,参数类型为 int;
"typedef int* Func(int)"中 Func 是函数类型(函数返回值类型为 int*,参数类型为 int)
的一个 typedef-name。
Func *fptr; <=> fptr 是一个 pointer to function with one int parameter, returning a
pointer to int
Func f; 这样的声明意义就不大了。
上一篇:VS2019中安装使用Qt
下一篇:java变量,数据类型,转换