i have the following:
class base
{
public
void f();
...
}
void base::f()
{
static bool indicator=false;
.....
if(!indicator)
{
...
indicator=true;
}
}
class D:public base
{
...
}
in my main() i have:
main()
{
// first instance of D
base *d1 = new D();
d1->f();
....
// 2nd instance of D
base *d2 = new D();
d2->f();
}
i find that the first time i instantiate D and call d1->f() the static variable is set to false. but the 2nd time i call d2->f() the code does not even hit the line "static bool indicator=false;" and it is kept at true (from the first pass of d1-f()) This is exactly the behavior i want but i do not understand why this is happening. can someone please explain what is happening. thanks in advance