CPP Function Variable Scope.

What is Variable Scope.

  • It is to determines how long the variable is available to your program code and where it can be accessed.

Local Variables

  • Variables declared within a block are scoped to that block and is local for the block. Those variables they can be accessed only within that block's braces.
  • For a function, all variables defined inside the body of the function and parameters are local and can only be accessed inside the body of the function.

Global Variables

  • Variables defined outside of any function have global scope, and thus are available from any function in the program, including the main() function.
  • Local variables that have the same name as any global variables do not change the global variables.
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.