c – 这个typedef定义是什么意思?
发布时间:2020-12-16 03:14:14 所属栏目:百科 来源:网络整理
导读:我看到以下(C): typedef n *(m)(const n*,const n*); 这是什么意思,怎么用? 我明白了 typedef n (*myFunctP)(const n*,const n*); 但是上面的typedef有什么区别? (希望这不重要,没有找到类似的东西…) 解决方法 我问 geordi赢了我一些代表: tomalak TYPE
我看到以下(C):
typedef n *(m)(const n*,const n*); 这是什么意思,怎么用? 我明白了 typedef n (*myFunctP)(const n*,const n*); 但是上面的typedef有什么区别? (希望这不重要,没有找到类似的东西…) 解决方法
我问
geordi赢了我一些代表:
<tomalak> << TYPE_DESC<m>; struct n {}; typedef n *(m)(const n*,const n*); <geordi> function taking 2 pointers to constant ns and returning a pointer to a n C类声明语法是可怕的,当你开始这样做复杂的声明时,它变得特别明显.注意返回类型和参数是如何写在m上的,而不是n,这完全是向后直觉,因为它是你创建的. 你的第二个例子是: <tomalak> << TYPE_DESC<m>; struct n {}; typedef n (*m)(const n*,const n*); <geordi> pointer to a function taking 2 pointers to constant ns and returning a n 通过移动*,您不再将其应用于函数类型的返回类型,而是将其应用于函数类型本身. 在C11中,除非你绝对需要你的电话是超高效的,请坚持下列,为Cthulhu的爱! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |