c++ - 这个 typedef 语句是什么意思?

标签 c++ typedef

在 C++ 引用页面中,他们提供了一些 typedef 示例,我试图理解它们的含义。

// simple typedef
typedef unsigned long mylong;


// more complicated typedef
typedef int int_t, *intp_t, (&fp)(int, mylong), arr_t[10];

所以我理解的简单 typedef(第一个声明)。

但是他们用第二个(下面重复)声明了什么?

typedef int int_t, *intp_t, (&fp)(int, ulong), arr_t[10];

(&fp)(int, mylong)具体是什么意思?

最佳答案

它一次声明多个 typedef,就像您可以一次声明多个变量一样。它们都是基于int的类型,但有些被修改为复合类型。

让我们把它分解成单独的声明:

typedef int int_t;              // simple int
typedef int *intp_t;            // pointer to int
typedef int (&fp)(int, ulong);  // reference to function returning int
typedef int arr_t[10];          // array of 10 ints

关于c++ - 这个 typedef 语句是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22061750/

相关文章:

c++ - 非线性颜色插值?

c++ - 为什么在使用对象作为多映射中的键时,析构函数被调用得太多了

c++ - 为什么模板 typedef 是 C++(不是 C++11)中的一个问题

C : Static to dynamic allocation on multiple dimension array

c - 这种声明有什么用呢?

c - typedef 一个函数接口(interface)(不是函数指针)

c++ - 将类的任何模板存储在另一个类中

c++ - 定时器、线程和编译器的错误行为

C++ OpenCV : tracking moving people on the street

c - 类型定义,#define