Function level variable : function scope variables « Function « C++ Tutorial






#include <iostream> 
using namespace std; 
 
void f1(); 
 
int main() 
{ 
  int val = 10; 
 
  cout << "val in main(): " << val << '\n'; 
  f1(); 
  cout << "val in main(): " << val << '\n'; 
 
  return 0; 
} 
 
void f1() 
{ 
  int val = 88; 
 
  cout << "val in f1(): " << val << "\n"; 
}
val in main(): 10
val in f1(): 88
val in main(): 10








7.15.function scope variables
7.15.1.Function level variable
7.15.2.A local variable is initialized each time its block is entered