#include <iostream>
usingnamespace std;
void myFunc1(); // function with non static var
void myFunc2(); // function with static var
int main()
{
for (int i = 0; i < 5; i++) { // when you run the program notice that i for
myFunc1();//function 1 aways gets reset back to 0 while function2's i
myFunc2();//increments and retains its previous value.
}
return 0;
}
void myFunc1()
{
int i = 0;
cout<< "Non static var " << i << endl;
i++;
}
void myFunc2()
{
staticint i = 0;
cout << "This is static var: " << i << endl;
i++;
}