Writing Generic Code with Templates

作者
Marc Gregoire
标识
DOI:10.1002/9781119421276.ch12
摘要

C++ provides language support not only for object-oriented programming, but also for generic programming. The goal of generic programming is to write reusable code.The fundamental tools for generic programming in C++ are templates. This chapter starts with a discussion on using templates for generic programming. It then describes the syntax on how to write templates and examples where templates are really useful. It explains how to write class templates, how to organize the code in different files, how to use template parameters, and how to templatize methods of a class. It further discusses how to use class template specialization to write special implementations of a template where the template parameters are replaced with specific arguments. In order to understand class templates, it is helpful to examine the syntax. The chapter finishes with an explanation of function templates and variable templates.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
麦子发布了新的文献求助10
刚刚
知夏关注了科研通微信公众号
1秒前
2秒前
3秒前
hautzhl完成签到,获得积分10
4秒前
clwh2006完成签到,获得积分10
4秒前
4秒前
无情的函发布了新的文献求助10
4秒前
4秒前
哦吼完成签到 ,获得积分10
6秒前
7秒前
露露完成签到,获得积分10
7秒前
nano发布了新的文献求助10
8秒前
彭于晏的应助被zzz采纳,获得10
8秒前
周zhou完成签到,获得积分10
8秒前
橙子完成签到,获得积分10
8秒前
8秒前
9秒前
刘海辉完成签到,获得积分10
9秒前
美满黄豆发布了新的文献求助10
10秒前
10秒前
调皮的蝴蝶完成签到 ,获得积分10
11秒前
在水一方的应助被hrj采纳,获得10
12秒前
上面密密麻麻完成签到 ,获得积分10
12秒前
内向南风完成签到 ,获得积分10
13秒前
贝果发布了新的文献求助10
13秒前
3089ggf发布了新的文献求助10
13秒前
asd发布了新的文献求助10
14秒前
飞飞的应助被zyjsunye采纳,获得10
14秒前
神勇的雅容完成签到,获得积分10
14秒前
zzz发布了新的文献求助10
15秒前
cccl完成签到 ,获得积分10
18秒前
CodeCraft的应助被beigu采纳,获得10
19秒前
所所的应助被warmen采纳,获得10
19秒前
20秒前
Ming完成签到,获得积分10
20秒前
阿东完成签到,获得积分10
20秒前
难过的谷芹的应助被HaoYongzeng采纳,获得10
20秒前
科研通AI6.4的应助被我爱静静采纳,获得10
22秒前
完美世界的应助被阿东采纳,获得10
23秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
Nanocomposite Removal of Pesticides from Wastewater 2000
Essentials of Carbohydrate Chemistry and Biochemistry, 4th Edition 1000
Электротехническая система магнитожидкостной герметизации валов регулируемых электродвигателей 800
日本語と中国語及びチベット・ビルマ語の語源関連性に関する分析 800
Practical Manual of Forensic Psychophysiology: Methodology, Execution, and Fields of Application 800
Holistic Discourse Analysis, Second Edition by Robert E. Longacre 666
热门求助领域 (近24小时)
化学 材料科学 医学 生物 计算机科学 工程类 纳米技术 有机化学 物理 生物化学 化学工程 内科学 复合材料 催化作用 心理学 人工智能 细胞生物学 光电子学 无机化学 量子力学
热门帖子
关注 科研通微信公众号,转发送积分 7945966
求助须知:如何正确求助?哪些是违规求助? 9426826
关于积分的说明 20981988
捐赠科研通 7531023
什么是DOI,文献DOI怎么找? 3368282
关于科研通互助平台的介绍 2504703
邀请新用户注册赠送积分活动 2400109