Skip to Content
C++程序设计:原理与实践(基础篇)(原书第2版)
book

C++程序设计:原理与实践(基础篇)(原书第2版)

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
9h 36m
Chinese
Pearson
Content preview from C++程序设计:原理与实践(基础篇)(原书第2版)

14.3.6 模板实参推断

对于一个类模板,当你创建某个特定类的对象时,需要指定模板实参。例如:

对于函数模板,编译器通常能够根据函数实参推断出模板参数。例如:

在技术上,fill(buf,'x')是fill<char,1024>(buf,'x')的简写,fill(b2,0)是fill<double,10>(b2,0)的简写。幸运的是,我们通常并不需要编写这么具体的代码。编译器能够为我们做这些事情。

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉

Publisher Resources

ISBN: 9787111562252