S
subramanian
Hello.
Consider the following code fragment :
enum TestEnum { val1 = 10, val2 = 100, val3 = 1000 };
class Test {
public :
enum TestEnum { val1 = 1, val2 val3 };
Test(int i = 0, int j = 0, TestEnum val = TestEnum(0));
...
private :
int x, y;
TestEnum a;
static Test default_test;
};
Test Test::default_test(1, 2, val1);
int main(void)
{
Test temp_test(1, 2, val1);
...
}
--------------------------------------------------------------
QUESTIONS:
1)
I am getting compilation error for Test temp_test(1, 2, val1); val1 is
not taken from global enum TestEnum nor the Test::val1. However in the
static member definition,
Test Test::default_test(1, 2, val1);
val1 is considered to be Test::val1. Here I am not getting compilation
error. Why is this difference, considering that both are ctors where
val1 appears.
2)
In the static class member definition
Test Test::default_test(1, 2, val1);
val1 is taken from Test::val1. Why is not the global val1 considered ?
Consider the following code fragment :
enum TestEnum { val1 = 10, val2 = 100, val3 = 1000 };
class Test {
public :
enum TestEnum { val1 = 1, val2 val3 };
Test(int i = 0, int j = 0, TestEnum val = TestEnum(0));
...
private :
int x, y;
TestEnum a;
static Test default_test;
};
Test Test::default_test(1, 2, val1);
int main(void)
{
Test temp_test(1, 2, val1);
...
}
--------------------------------------------------------------
QUESTIONS:
1)
I am getting compilation error for Test temp_test(1, 2, val1); val1 is
not taken from global enum TestEnum nor the Test::val1. However in the
static member definition,
Test Test::default_test(1, 2, val1);
val1 is considered to be Test::val1. Here I am not getting compilation
error. Why is this difference, considering that both are ctors where
val1 appears.
2)
In the static class member definition
Test Test::default_test(1, 2, val1);
val1 is taken from Test::val1. Why is not the global val1 considered ?