2.16 Type Names

In several contexts a type name can or must be specified without an identifier. For example, in a function prototype declaration, the parameters of the function can be declared only with a type name. Also, when casting an object from one type to another, a type name is required without an associated identifier. (Section 6.4.6 has information on casting, and Section 5.5 has information on function prototypes.) This is accomplished using a type name, which is a declaration for a function or object which omits the identifier.

Table 2-1 shows examples of type names with the associated types they refer to.

Table 2-1 Type Name Examples

Construction  Type Name 
int   int  
int *   Pointer to int  
int *[3]   Array of three pointers to int  
int (*)[3]   Pointer to an array of three int
int *()   Function with no parameter specification returning a pointer to int  
int (*) (void)   Pointer to function with no parameters returning an int  
int (*const []) (unsigned int, ...)   Array of an unspecified number of const pointers to functions, each with one parameter that has type unsigned int and an unspecified number of other parameters, returning an int  

Table 2-1 also provides good examples of abstract declarators. An abstract declarator is a declarator without an identifier. The characters following the int type name form an abstract declarator in each case. The * , [ ] , and ( ) characters all indicate a declarator without naming a specific identifier.


Previous Page | Next Page | Table of Contents | Index