[英]What does 'template <typename> class X' mean?
斯坦·利普曼等 al (in "C++ Primer ", 5/e) ,说:
1 // forward declarations needed for friend declarations in Blob
2 template <typename> class BlobPtr;
3 template <typename> class Blob; // needed for parameters in operator==
4 template <typename T>
5 bool operator==(const Blob<T>&, const Blob<T>&);
6 template <typename T> class Blob {
7 // each instantiation of Blob grants access to the version of
8 // BlobPtr and the equality operator instantiated with the same type
9 friend class BlobPtr<T>;
10 friend bool operator==<T>
11 (const Blob<T>&, const Blob<T>&);
12 // other members as in § 12.1.1 (p. 456)
13 };
我并没有真正理解第 2 行和第 3 行中的template <typename>
部分。我尝试搜索,但找不到任何清晰和实质性的内容来阅读有关template <typename>
更多信息。
请帮助我提供一些关于阅读更多关于声明的指示,例如
template <typename> class BlobPtr
template <typename> class BlobPtr;
这是类模板的声明。 模板的名称是BlobPtr
,它有一个模板类型参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.