Export (0) Print
Expand All

C++ Abstract Declarators

An abstract declarator is a declarator in which the identifier is omitted. (For related information, see Type Names.)

The following abstract declarators are discussed in this section:

An abstract declarator is a declarator that does not declare a name — the identifier is left out. For example,

char *

declares the type "pointer to type char." This abstract declarator can be used in a function prototype as follows:

char *strcmp( char *, char * );

In this prototype (declaration), the function's arguments are specified as abstract declarators. The following is a more complicated abstract declarator that declares the type "pointer to a function that takes two arguments, both of type char *," and returns type char *:

char * (*)( char *, char * )

Since abstract declarators completely declare a type, it is legal to form expressions of the form:

// Get the size of array of 10 pointers to type char.
size_t nSize = sizeof( char *[10] );

// Allocate a pointer to a function that has no
//  return value and takes no arguments.
typedef void (PVFN *)();
PVFN *pvfn = new PVFN;

// Allocate an array of pointers to functions that
//  return type WinStatus, and take one argument of
//  type WinHandle.
typedef WinStatus (PWSWHFN *)( WinHandle );
PWSWHFN pwswhfnArray[] = new PWSWHFN[10];

See Also

Declarators

Show:
© 2014 Microsoft