typename as we know in C++ is used in template.
The difference between typename and class is in the nested type.
Take the class sp in RefBase.h of Android Framework as example:
template <typename T>
class sp
{
public:
typedef typename RefBase::weakref_type weakref_type;
.........
}
class RefBase
{
public:
.........
class weakref_type
{
.........
}
}
--------------------------
Notice that " typedef typename RefBase::weakref_type weakref_type; "
Compiler will not know that if weakref_type is a variable of RefBase. Compiler will know that weakref_type is a type or class of RefBase by giving typename .
沒有留言:
張貼留言