What you need to do is the following:
BaseClass::NestedClass bar;
You cannot avoid using the scope resolution operator, but you can make a typedef
as a shorthand in the appropriate scope:
typedef BaseCLass::NestedClass NestedClass;
EDIT:
Based on the change in question, if you would like the type from an instance, in c++11 you can use decltype
:
decltype(foo)::NestedClass;
but this is pointless as decltype
would return BaseClass in this instance.