共用方式為


C 抽象宣告子

抽象宣告子是一個沒有識別項的宣告子,由一個或多個指標、陣列或函式修飾符組成。 指標修飾詞 (*) 永遠會位於宣告子的識別項之前,陣列 ([ ]) 和函式 ( ( ) ) 修飾詞會位於識別項的後方。 知道這一點後,您就可以判斷識別項會出現在抽象宣告子的哪個位置,並據以解譯宣告子。 如需複雜宣告子的詳細資訊和範例,請參閱解譯更複雜的宣告子。 通常可使用 typedef 來簡化宣告子。 請參閱 Typedef 宣告

抽象宣告子可能很複雜。 複雜抽象宣告子中的括號會指定特定的解譯,就如同在宣告中針對複雜宣告子所做的動作。

這些範例說明抽象宣告子:

int *         // The type name for a pointer to type int:

int *[3]      // An array of three pointers to int

int (*) [5]   // A pointer to an array of five int

int *()       // A function with no parameter specification
              // returning a pointer to int

// A pointer to a function taking no arguments and
// returning an int

int (*) ( void )

// An array of an unspecified number of constant pointers to
// functions each with one parameter that has type unsigned int
// and an unspecified number of other parameters returning an int

int (*const []) ( unsigned int, ... )

注意

由一組空括號 "( )" 組成的抽象宣告子會造成模稜兩可的情況,因此不允許使用。 要判斷隱含的識別項是落在括號內部 (在此情況下它是未經修改的類型) 或在括號前面 (在此情況下它是函式類型) 是不可能的。

另請參閱

宣告子和變數宣告