class Foo
{
public:
void bar();
};
void Foo::bar()
{
static int n = 0;
printf("%d\n", n++);
}
int main(int argc, char **argv)
{
Foo *f = new Foo();
f->bar();
delete f;
f = new Foo();
f->bar();
delete f;
return 0;
}
Does n
reset to 0
after delete
'ing and new
'ing the class over again? Or is n
effectively a static class member (same reference in all instances)?
In other words, should I get
0 0
or
0 1
?