The Structure of Declarations

Declarations is specifying the properties of an identifier. In c++, the declaration have five parts:

• Optional prefix specifiers like static, extern etc
• A base type like int, char, const float etc
• A declarator like p[7] , n etc
• Optional suffix function specifiers like const, noexcept etc
• An optional initializer or function body like =34, (2), {1}, { return 1;} etc

A specifier is an initial keyword, such as virtual, extern or constexpr that specifies some non-type attribute of what is being declared.

So, Any declaration whether it is variable or function will have above five parts which three are optional parts.


static int function() const {    return x;
int a = 12;

Except for function and namespace definitions, a declaration is terminated by a semicolon.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s