TITLE: ensuring identical typedefs in templates (Newsgroups: comp.lang.c++, 18 Sep 99) BUNJONGSAT: Waranun Bunjongsat >But, what I'd like to guarantee is that I want to make sure template >parameter "a" of X is the same as template parameter "a" of B. > >I know that we can do this. > >template >class u> >class B : public A, private u { ... } > >But I think it's a bad style. Because it increases the level of code >bloat. Should avoid. However, I do not know other ways to do this. NARAN: Siemel B. Naran I'm not sure if there will be additional code bloat. But class B does have a few more template arguments. The trick is to typedef a type twice in the same scope. The compiler will complain if the two typedefs differ. template class B : public A, private x { typedef a a_type; typedef typename x::a_type a_type; public: private: };