What are declarations and declarators and how are their types interpreted by the standard?

后端 未结 2 975
鱼传尺愫
鱼传尺愫 2020-11-30 17:49

How exactly does the standard define that, for example, float (*(*(&e)[10])())[5] declares a variable of type \"reference to array of 10 pointer to function

2条回答
  •  情深已故
    2020-11-30 18:24

    Here's the way I parse float const (*(*(&e)[10])())[5]. First of all, identify the specifier. Here the specifier is float const. Now, let's look at the precedence. [] = () > *. The parentheses are used to disambiguate the precedence. With precedence in mind, let's identify the variable ID, which is e. So, e is a reference to an array (since [] > *) of 10 pointers to functions (since () > *) which take no argument and return and a pointer to an array of 5 float const. So the specifier comes last and rest are parsed according to the precedence.

提交回复
热议问题