Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
A local variable is a variable that has a limited scope.
In the example below, there are three different local variables called 'x'. In the function A, x is local to this function and exists after it definition. In the function B, x is a function argument local to this function. In main, x is local to this function and has nothing to do with the other x's.
#include <iostream> |
Declare variables as locally as possible [1].
Compare the speed of local versus global variables.
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.