I'm trying to understand Scope resolution operator ::
I know I can only access static class member via Scope resolution operator.
But I can use it to access typedef or a nested class thing like this:
class test{
public:
class testinner{
public:
int _val;
testinner(){}
testinner(int x):_val(x){}
};
test(){}
typedef int testdef;
int s;
};
int main()
{
test::testinner tt1 = test::testinner(5); //OK LINE(1)
test::testinner tt2; //OK LINE(2)
test::testdef tt3 = 5; //OK LINE(3)
test::s = 5; //non static member ERROR LINE(4)
return 0;
}
I can instantiate an in-class type object via :: such as line 1 and line 2
I can use typedef to instantiate an object such as line 3
I can't access non-static members via :: such as line 4
Is that mean an in-class class and typedef is a static member in a class? I know namespace is quite equal to class name but I'm still really getting confused about it.
By the way, for the typedef part, can I simply think tt3 is int type rather than test::testdef type?