/* testfunc08.cpp CIS 150 6/9/2005 David Klick This program demonstrates static local variables. */ #include using std::cout; int counter1(); // function prototype int counter2(); // function prototype int main(void) { int i; for (i=0; i<9; i++) { cout << counter1() << ", " << counter2() << '\n'; } return 0; } /* Increment counter by 10 and return value. (non-static counter) */ int counter1() { int count = 0; count += 10; return count; } /* Increment counter by 10 and return value. (static counter) */ int counter2() { static int count = 0; count += 10; return count; } /* Sample output: 10, 10 10, 20 10, 30 10, 40 10, 50 10, 60 10, 70 10, 80 10, 90 */