cpp-book/src/generic/generic-class.md
2024-02-05 23:09:03 +08:00

13 lines
341 B
Markdown

# 类模板
类模板与函数模板的定义格式类似,也是将`template`关键字和模板形参表放置在类定义关键字`class`之前,其声明格式如下:
```c++
template <typename 类型形参名称>
class 类名称 {
类声明
}
```
类模板在使用时必须显式指定类型实参,例如`Queue<int> qi;`。