void func1(int i) {
static int staticInt=i;
cout<< staticInt << endl;
}
int main() {
func1(1);
func1(2);
}
Output of this code:
1
1
Reason:
Initialization statement will be executed once only as static variables are initialized once.
void fucn1(int i) {
static int staticInt;
staticInt=i;
cout<< staticInt << endl;
}
int main() {
func1(1);
func1(2);
}
Output of this code:
1
2