Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Declarations

Declarations introduce new names into a program. Topics covered in this section include the following uses for declarations:

In addition to introducing a new name, a declaration specifies how an identifier is to be interpreted by the compiler. Declarations do not automatically reserve storage associated with the identifier — reserving storage is done by definitions.

Note   Most declarations are also definitions.

Grammar

declaration:
decl-specifiersopt declarator-listopt ;
function-definition
linkage-specification
template-specification

The declarators in declarator-list contain the names being declared. Although the declarator-list is shown as optional, it can be omitted only in declarations or definitions of a function.

Note   The declaration of a function is often called a "prototype." This declaration provides type information about arguments and the function's return type that allows the compiler to perform correct conversions and to ensure type safety.

The decl-specifiers part of a declaration is also shown as optional; however, it can be omitted only in declarations of class types or enumerations.

Declarations occur in a scope. This controls the visibility of the name declared and the duration of the object defined (if any). For more information about how scope rules interact with declarations, see Scope.

An object declaration is also a definition unless it contains the extern storage-class specifier described in Storage-Class Specifiers. A function declaration is also a definition unless it is a prototype — a function header with no defining function body. An object's definition causes allocation of storage and appropriate initializations for that object.

See Also

C++ Language Reference

Show:
© 2014 Microsoft