P
prava sahoo
class foo
{
static int xxx;
static int zzz;
};
static int xxx =2;
int foo::xxx = 1; // error here
int foo::zzz = 1;
static int zzz =2;
When compiled (gcc 2.4.5) It give an error for redefining xxx, but
not
for zzz,
because xxx is a static variable and its scope is inside the total
program so we can create only a single copy of this variable but zzz
in general variable inside class foo zzz is local to that class
foo .outside the class zzz is a variable of the program program .
these are consider two different variable with same name.
{
static int xxx;
static int zzz;
};
static int xxx =2;
int foo::xxx = 1; // error here
int foo::zzz = 1;
static int zzz =2;
When compiled (gcc 2.4.5) It give an error for redefining xxx, but
not
for zzz,
because xxx is a static variable and its scope is inside the total
program so we can create only a single copy of this variable but zzz
in general variable inside class foo zzz is local to that class
foo .outside the class zzz is a variable of the program program .
these are consider two different variable with same name.