saneha
04-29-2011, 08:32 AM
Static Variable in c++ 2011
Vuhelper
04-29-2011, 08:32 AM
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.