typename除了可以在模版中使用以外,还可以显示的说明某个东东其实是一个类型
#include <iostream.h>
class MyArray
{
public:
typedef int LengthType;
};
class MyArray2
{
public:
static int LengthType;
};
int MyArray2::LengthType = 1;
MyArray::LengthType i = 0;
template<class T>
void MyMethod( T myarr )
{
typedef T::LengthType LengthType;
LengthType length = 1;
}
int main()
{
MyArray2 myarr;
MyMethod(myarr);
return 0;
}