Declaration Statements
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Declaration Statements (C++)

Declaration statements introduce new names into the current scope. These names can be:

  • Type names (class, struct, union, enum, typedef, and pointer-to-member).

  • Object names.

  • Function names.

Declarations may be any of the following:

block-declaration 
function-definition 
template-declaration 
explicit-instantiation 
explicit-specialization 
linkage-specification 
namespace-definition

If a declaration within a block introduces a name that is already declared outside the block, the previous declaration is hidden for the duration of the block. After termination of the block, the previous declaration is again visible.

Multiple declarations of the same name in the same block are illegal.

For more information about declarations and name hiding, see Declarations and Definitions and Scope.

Show:
© 2016 Microsoft