template class isint { typedef double t; }; template<> class isint { typedef int t; }; template class X { template class Y { typedef x ff; typedef typename isint::t fff; }; }; template class Z { typedef typename X::template Y::ff one; typedef typename X::template Y::fff two; }; Z d;