search

Home  >  Q&A  >  body text

c++ - 分析这句CPP代码:typedef action_t* (*rule_t)(const sandbox_t*, const event_t*, action_t*);

在分析一个源码源码的时候看到了这么一句话:

typedef action_t* (*rule_t)(const sandbox_t*, const event_t*, action_t*);

。。。然后我就晕了。。。

呃。。。仔细看了看。。然后就明白了……
就是说一个叫做action_t类型的东西是个函数指针。。。(rule_t)是返回值类型,(const sandbox_t*, const event_t*, action_t*)是参数表

ringa_leeringa_lee2804 days ago599

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-17 11:22:24

    rule_t is the name of typedef, which represents

    返回值是action_t*, 参数是(const sandbox_t*, const event_t*, action_t*)的函数指针类型
    

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:22:24

    Obviously not what you said!

    action_t* is the return type
    rule_t is the name of the function pointer
    The following is the parameter table

    In fact, we shouldn’t say that. We should say that rule_t is a function pointer, and the signature of the function it points to is similar to the following:

    action_t* func(const sandbox_t*, const event_t*, action_t*);
    

    reply
    0
  • Cancelreply