Say I have an object of some of stl container classes obj. I can define other object of same type this way:
decltype(obj) obj2;
<
Your code is well-formed according to the final C++0x draft (FDIS). This was a late change that's not yet been implemented by the Visual Studio compiler.
In the meantime, a workaround is to use a typedef:
typedef decltype(obj) obj_type;
obj_type::iterator it = obj.begin();
EDIT: The relevant chapter and verse is 5.1.1/8:
qualified-id:
[...]
nested-name-specifier templateopt unqualified-id
nested-name-specifier:
[...]
decltype-specifier ::
decltype-specifier:
decltype ( expression )
And for completeness's sake:
The original core issue
Proposal for wording