// Steve J Hodges, Fall 2003 // CS19 example program // "Don't try this at home" // (side effects and static) // badprog.cpp #include using namespace std; int badfn(); main(){ cout << "result of badfn() is " << badfn() << endl; cout << "result of badfn() is " << badfn() << endl; cout << "result of badfn() is " << badfn() << endl; } // this bad fn demonstrates the // "bad" way to use the static "storage class" keyword // only shown so that you will know not to do this int badfn(){ static int evilVariable=0; evilVariable++; cout << "side note: this print is a side effect\n"; return evilVariable; }