article

In computer science, a declaration specifies a variable's dimensions, identifier, type, and other aspects. The declaration, and any related initializer, forms the definition; usually, the declaration and definition are the same thing. Definitions reserve memory. Definitions and declarations can also be used for subroutines (functions); where, they are sometimes referred to as "prototypes". Once again, in some cases the definition and the prototype are the same thing.

Initialization allows a program to assign an initial value to a variable. Below is an example of a function in C and C++ (the syntax is the same in this case) which declares an integer variable, x; this is followed by an example where the variable has been initialized to seven, x = 7:

These below are the examples of declaration

void example1()
{
 int x;
}

void example2()
{
 int x = 7;
}
These below are the examples of Definition
void example2();

It ends with a semicolon because it is a Prototype of a function(which do not return anything)

See also


Computer programming | Programming constructs

 

This article is licensed under the GNU Free Documentation License. It uses material from the "Declaration (computer science)".

Home Pageartsbusinesscomputersgameshealthhospitalshomekids & teensnewsphysiciansrecreationreferenceregionalscienceshoppingsocietysportsworld