Type Names - Abstract Declarators


Type names may be used in conversions or as a parameter of the operator sizeof. Type names specified in this way are syntactically equivalent to a declaration without the declarator name. Shown below is the syntax of type names and abstract declarators (which may be compared with the syntax of standard declarators).

Syntax

type_name:
       type_specifier_list abstract_declarator
 
type_specifier_list:
       type_specifier type_specifier_list
 
abstract_declarator:
       pointer_operator abstract_declarator
       abstract_declarator (parameter_declaration_list) constant_volatile_qualifier_list
       abstract_declarator [constant_expression]
       (abstract_declarator)
 
pointer_operator:
        * constant_volatile_qualifier_list
        & constant_volatile_qualifier_list
        complete_class_name :: * constant_volatile_qualifier_list
 
constant_volatile_qualifier_list:
       constant_volatile_qualifier constant_volatile_qualifier_list
 
constant_volatile_qualifier:
        const
        volatile

Notes

For any type declaration, it is possible to select a unique position within the declaration such that if a declarator_name is inserted at that position the type declaration becomes an actual declaration.

Examples

The following are examples of type declarations.

double            // double n
double[5]         // double array[5] - array of five numbers
double*[5]        // double* array[5] - array of five pointers to double
int (*)(int,int)  // int (*pf)(int,int) - pointer to function taking two integers and returning integer

The comments provide a declaration of an object of the same type as the type name declared on the left.