我正在研究一个示例代码,它尝试教授状态图的实现。我看到了模板的typedef如typedef typename T::HostClass Host
了解模板内的typedefs
为了清楚起见,模板定义为
template<typename T>
struct Init {
typedef typename T::HostClass Host;
Init(Host& h) :
host_(h) {
}
~Init() {
T::entry(host_);
T::init(host_);
}
Host& host_;
};
我才知道的typename
目的旁边typedef
,并解释Highly-Typed-Languages
如C++
(伙计们,我是不是对不对?是不是这样呢?)
的困惑是在HostClass
在typedef typename T::HostClass Host;
- 什么是
HostClass
? - 是否意味着任何类型T必须有会员
HostClass
?
该tut是从这个页面。 ''http:// accu.org/index.php/Journals/252' – nmxprime