why to use static keyword in c++ code example
Example: static inside local scope in c++
#include<iostream>
class SingleTon {
public:
static SingleTon& Get() {
static SingleTon s_Instance;
return s_Instance;
}
void Hellow() {}
};
void Increment() {
int i = 0;
i++;
std::cout << i << std::endl;
};
void IncrementStaticVar() {
static int i = 0;
i++;
std::cout << i << std::endl;
}
int main() {
Increment();
Increment();
Increment();
IncrementStaticVar();
IncrementStaticVar();
IncrementStaticVar();
IncrementStaticVar();
SingleTon::Get();
std::cin.get();
}