|
|
These are two valid declarations of variables. The first one declares a variable of type
int
with the identifier a
. The second one declares a variable of type float
with the identifier mynumber
. Once declared, the variables a
and mynumber
can be used within the rest of their scope in the program.If declaring more than one variable of the same type, they can all be declared in a single statement by separating their identifiers with commas. For example:
|
|
This declares three variables (
a
, b
and c
), all of them of type int
, and has exactly the same meaning as:
|
|
To see what variable declarations look like in action within a program, let's have a look at the entire C++ code of the example about your mental memory proposed at the beginning of this chapter:
|
|
4 |
Don't be worried if something else than the variable declarations themselves look a bit strange to you. Most of it will be explained in more detail in coming chapters.