Check out example codes for "static inside local scope in c++". It will help you in understanding the concepts better.

Code Example 1

//Singleton class is a class having only one instance
class SingleTon {

	static SingleTon& Get() {
		static SingleTon s_Instance;
		return s_Instance;
	}//there is only one instance of static functions and variables across all instances of class
	void Hellow() {}
void Increment() {
	int i = 0;//The life time of variable is limited to the function scope
	std::cout << i << std::endl;
};//This will increment i to one and when it will reach the end bracket the lifetime of var will get  destroyed
void IncrementStaticVar() {
	static int i = 0;//The life time of this var is = to program
	std::cout << i << std::endl;
}//This will increment i till the program ends
int main() {
	Increment();//output 1
	Increment();//output 1
	Increment();//output 1
	IncrementStaticVar();// output 2
	IncrementStaticVar();// output 3
	IncrementStaticVar();// output 4
	IncrementStaticVar();// output 5


Learn ReactJs, React Native from