This example demonstrates global and local variables, their scopes and scope resolution operator(::).
This example demonstrates global and local variables, their scopes and scope resolution operator(::).
This example demonstrates the declaration and initialization of variables. Variables are used to hold data or useful information.
This example demonstrates local and global variables.
Local Variables :
Just like any other variable, string type variable's are initialized & assigned similarly.
Header file string must be included & data-type should be string.
An easiest way of assigning data to variable is :
data-type variable-name = value
The the assignment of values are done from right-to-left order, according to C++ standards.
Global Variables are known throughout the program and they may be used by any piece of code. They are very helpful when many functions in your program use the same data.
Variables that are declared inside a function are called "Local Variable".
Local variables may be referenced only by statements that are inside the block in which the variables are declared.
The const keyword specifies that a variable's value is constant and tells the compiler to prevent the programmer from modifying it. In C++, you can use the const keyword to define constant values.