65,187
社区成员




#include <iostream>
#include <typeinfo>
int f () { return 0; }
int main ()
{
using f_t = int(); // define function type
using pf_t = f_t*; // define pointer-to-function type
pf_t pf = f; // pointer-to-function definition
std::cout << typeid(f_t).name() << std::endl;
std::cout << typeid(pf_t).name() << std::endl;
std::cout << pf() << std::endl;
return 0;
}
typedef 用在一个普通的变量定义语句之前就是typedef 的标准用法了。
定义一个函数指针:
int (*pf)();
定义一个函数指针类型:
typedef int (*pf)();