The standard talks about the type of object that a variable represents.
You need to access the scope of the class, not the variable.
And in order to access the members of a nested class from U , you need to create an element from this type, there are two ways to do this:
struct U { struct A { static int v; int a; } VarNameForA; struct B { int b; }; B VarNameOfB; };
Use the scope operator :: to access types.
Here's how you do everything you've tried:
U a; typedef decltype(a) varType; typedef varType::A nestedType; int main() { std::cout << typeid(U::A).hash_code(); struct U::A b; U u; u.VarNameForA.a = 5; u.VarNameOfB.b = 6; U::A::c = 3; }
For participants, you use the dot (.) Operator; for types and statics, you need to use the scope :: operator.
source share