[C++] VectorSpace.H
- 
							
							
							
							
template<class Form, class Cmpt, int nCmpt> class VectorSpace { public: //- Component type typedef Cmpt cmptType;上面这句把模板参数 typedef 了,是做什么用呢? 然后 cmptType 出现在同文件夹的 products.H 中, template<class arg1, class arg2> class outerProduct { public: typedef typename typeOfRank < typename pTraits<arg1>::cmptType, int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) >::type type; };这个 outerProduct 类怎么理解? 
- 
							
							
							
							
							
							
@Wayne Hi, 我看了一下这个头文件。这个typeOfRank里面的 int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)是具体的值,比如矢量的outerProduct的值为2,矢量的intterProduct的值为0. 也就是说矢量外积为张量,内积为标量。typedef Cmpt cmptType;单说这个就是给cmpt取个别名叫做cmptType,在使用的时候,可以直接用这个cmptType,就是cmpt,但是它会随着模板变化。或许查查其他的头文件,会有用到cmpttype?
- 
							
							
							
							
谢谢回答。现在知道把模板参数 typedef 是为了可以输出模板参数的类型。参见C++ traits 
 
			
