scope rules
#include <iostream>
int main() {
// Scope rules
// determines wether an identifier can be used
// there are locar or block scope or global scope
// c++ uses static or lexicval scoping
// local or block scopes only visible within a block {} where declared
// not preserved between function calls, also when declared within nested block the outer blocks can't see in
// static local variable - initialized by first function called
// is preserved between function calls!! lives until programm is finished
static int value = 10;
// global scope - indentifier declare outside any function or class
// visible to all parts of the programm after has been declared
// example
int main() {
int num_ex = 100;
{
int num_ex = 200;
cout << num_ex << endl; // 200
}
cout << num_ex << endl; // 100
}
return 0;
}