//: C03:Static.cpp // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // Using a static variable in a function #include using namespace std; void func() { static int i = 0; cout << "i = " << ++i << endl; } int main() { for(int x = 0; x < 10; x++) func(); } ///:~