Static variables in static method in base class and inheritance
Posted
by Adal
on Stack Overflow
See other posts from Stack Overflow
or by Adal
Published on 2010-04-29T11:52:56Z
Indexed on
2010/04/29
11:57 UTC
Read the original article
Hit count: 851
I have these C++ classes:
class Base
{
protected:
static int method()
{
static int x = 0;
return x++;
}
};
class A : public Base
{
};
class B : public Base
{
};
Will the x
static variable be shared among A
and B
, or will each one of them have it's own independent x
variable (which is what I want)?
© Stack Overflow or respective owner