Declarations

The act of declaring an object (including variables, statics, etc.) instructs the compiler how much storage to allocate.

 

All objects must be declared before they can be used.*

 

A declaration specifies a data type and a list of one, or more identifiers (names) to call the variables / objects

 

int myVar ;

 

or:

int myVar, cat, dog, potato ; //4 integer variables declared

 

Multiple identifiers are separated by a comma. The above declares four variables of the data type int called myVar, cat, dog, potato.

 

*Note: Later we will see that functions must also be declared before they can be used

Leave a Reply